PID::FilePID files that guard against exceptions | |
Download |
PID::File Ranking & Summary
Advertisement
- License:
- Perl Artistic License
- Price:
- FREE
- Publisher Name:
- Rob Brown
- Publisher web site:
- http://karmatics.com/aardvark/
PID::File Tags
PID::File Description
PID::File is a Perl module for creating a pid file, or lock file, should be such a simple process.See Daemon::Control for a more complete solution for creating daemons (and pid files).The code for this module was largely borrowed from there.SYNOPSISCreate PID files. use PID::File; my $pid_file = PID::File->new; exit if $pid_file->running; if ( $pid_file->create ) { # do something $pid_file->remove; }Or perhaps a bit more robust... while ( $pid_file->running || ! $pid_file->create ) { print "Already running, sleeping for 2\n"; sleep 2; } $pid_file->guard; # if we get an exception at this point, $pid_file->remove() will be called automatically $pid_file->remove;Using a helper method... if ( $pid_file->create_or_wait( retries => 10, sleep => 5 ) ) { # do something $pid_file->remove; } else { # could not get lock }Product's homepage
PID::File Related Software