XAS::Lib::PidFile - A class to manage pid files within XAS
use XAS::Lib::PidFile; my $pid = XAS::Lib::PidFile->new( -pid => $$, -file => File('/', 'var', 'run', 'xas', 'process.pid') ); if ($pid->is_running) { printf("already running\n"); exit 2; } $pid->write(); ... $pid->remove();
This class will manage pid files for XAS. It loads mixins for individual platforms to help with determining if a process is already running. It uses discretionary directory locking to control access to the pid files.
This method initialize the module and takes this optional parameters.
Specifiy a pid file to use. This defaults to the pid file defined by XAS::Lib::Modules::Environment for the current procedure.
Define a pid number. This must be supplied
This method is loaded thru a mixin. It will attempt to load a currently existing pid file and check to see if that pid is active and if that running process is the same as the current procedure.
If it is, then it will return true. If not then it will return false.
Write the current pid to the pid file.
Remove the current pid file.
Kevin L. Esteb, <kevin@kesteb.us>
Copyright (c) 2012-2015 Kevin L. Esteb
TThis is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0. For details, see the full text of the license at http://www.perlfoundation.org/artistic_license_2_0.
To install XAS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm XAS
CPAN shell
perl -MCPAN -e shell install XAS
For more information on module installation, please visit the detailed CPAN module installation guide.