The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

XAS::Lib::PidFile - A class to manage pid files within XAS

SYNOPSIS

  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();
  

DESCRIPTION

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.

METHODS

new

This method initialize the module and takes this optional parameters.

-file

Specifiy a pid file to use. This defaults to the pid file defined by XAS::Lib::Modules::Environment for the current procedure.

-pid

Define a pid number. This must be supplied

is_running

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

Write the current pid to the pid file.

remove

Remove the current pid file.

SEE ALSO

XAS::Lib::Pidfile::Unix
XAS::Lib::Pidfile::Win32
XAS

AUTHOR

Kevin L. Esteb, <kevin@kesteb.us>

COPYRIGHT AND LICENSE

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.