NAME
Proc::PID::File::Fcntl - Manage PID files using fcntl() locks
SYNOPSIS
use Proc::PID::File::Fcntl;
my $pidfile = new Proc::PID::File::Fcntl;
DESCRIPTION
This Perl module permits callers to prevent multiple simultaneous instantiations of themselves. The module accomplishes this using a pidfile, which is used to obtain a lock.
Unlike the traditional pidfile locking protocol, which uses the existence and content of the file to indicate the lock, this module uses fcntl() locking of the file. This locking protocol is free of races and, assuming the lock file is not in a networked filesystem, is safe across OS crashes.
METHODS
$pidfile = Proc::PID::File::Fcntl->new( { opt => val, ... } )
Creates and locks a new pidfile, returning an object holding the lock. When the returned object goes out of scope, the lock is released.
Calls die
if the file cannot be opened or is locked by another process.
Must not be called when the calling process already has a lock on the pidfile, otherwise that lock will be released.
The options available include the following:
- path
-
Specifies the path name of the pidfile. Defaults to $0. If the value does not start with / then /var/run/ is prepended. If the value does not end with .pid then .pid is appended.
$pid = Proc::PID::File::Fcntl::getlocker( { opt => val, ... } )
Returns the PID of the process holding the lock on a pidfile or 0
if there is no such process.
Must not be called when the calling process already has a lock on the pidfile, otherwise that lock will be released.
The options available include the following:
- path
-
Specifies the path name of the pidfile. Defaults to $0. If the value does not start with / then /var/run/ is prepended. If the value does not end with .pid then .pid is appended.
AUTHOR
John Gardiner Myers <jgmyers@proofpoint.com>
SUPPORT
For help and thank you notes, e-mail the author directly. To report a bug, submit a patch, or add to the wishlist please visit the CPAN bug manager at: http://rt.cpan.org