Subject: | Doco bug? |
I think there is a race condition in the documented use of this module.
As currently stated:
use File::Pid;
my $pidfile = File::Pid->new({
file => '/some/file.pid',
});
$pidfile->write;
if ( my $num = $pidfile->running ) {
die "Already running: $num\n";
}
Thsi seems to always tell me it is always already running - as the PID
returned from running is the current script's PID. However, if I put the
write() call after the running() call, then it successfully catches
multiple instances of the same job firing up, as the running() call
catches PREVIOUS instances of the same script running:
use File::Pid;
my $pidfile = File::Pid->new({
file => '/some/file.pid',
});
if ( my $num = $pidfile->running ) {
die "Already running: $num\n";
}
$pidfile->write;