The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

PID::File - PID files, that just work.

VERSION

Version 0.02

SYNOPSIS

Create PID files.

 use PID::File;
 
 my $pid_file = PID::File->new;
 
 if ( $pid_file->running )
 {
     exit;
 }
 else
 {
     if ( $pid_file->create )
     {
         # do something with confidence here
 
         $pid_file->remove;
     }
     else
     {
         # either someone got in there just before you
         # or there's a serious filesystem problem
     }
 }

DESCRIPTION

Creating a pid file, or lock file, should be such a simple process, unfortunately other modules on CPAN have bugs and are not being maintained.

See Daemon::Control for a more complete solution for creating daemons (and pid files) - the code for this module was largely borrowed from there.

Methods

Class Methods

new

Instance Methods

file

The filename for the pid file.

Can be relative to the directory where your scripts runs, or absolute.

By default it will use the script name and append '.pid' to it.

create

Create a new pid file.

Returns true or false for whether the pid file was created.

If the file already exists, and the pid in that file is still running, no action will be taken and it will return false.

running

Returns true or false to indicate whether the pid in the current pid file is running.

remove

Removes the pid file.

AUTHOR

Rob Brown, <rob at intelcompute.com>

BUGS

Please report any bugs or feature requests to bug-pid-file at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=PID-File. I will be notified, and then you will automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc PID::File

You can also look for information at:

ACKNOWLEDGEMENTS

Daemon::Control

LICENSE AND COPYRIGHT

Copyright 2012 Rob Brown.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.