Acme-Ghost
view release on metacpan or search on metacpan
t/03-filepid.t view on Meta::CPAN
if (my $child = fork) { # Parent PID
sleep 1;
my $p = Acme::Ghost::FilePid->new(file => $file, autoremove => 1);
note sprintf "Parent PID: %s; Parent Owner: %s", $p->pid, $p->owner;
$p->save unless $p->running;
ok $p->running, 'child process is running';
#note explain $p;
waitpid $child, 0;
done_testing;
} else { # child process
my $p = Acme::Ghost::FilePid->new(file => $file, autoremove => 1); # hope for the best
unless ($p->running) {
$p->save;
note sprintf "Start child process (Child PID: %s; Child Owner: %s)", $p->pid, $p->owner;
sleep 3;
note sprintf "Finish child process (Child PID: %s; Child Owner: %s)", $p->pid, $p->owner;
}
#note 'parent is running' if $p->running;
}
__END__
( run in 1.871 second using v1.01-cache-2.11-cpan-4e96b696675 )