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

NAME

PkgForge::PidFile - A class to provide simple PID file handling

VERSION

This documentation refers to PkgForge::PidFile version 1.1.10

SYNOPSIS

     use PkgForge::PidFile;

     my $pidfile = PkgForge::PidFile->new();

     if ( $pidfile->is_running ) {
        my $pid = $pidfile->pid;
        die "daemon process ($pid) already running\n";
      }
      elsif ( $pidfile->does_file_exist ) {
        $self->pidfile->remove;
      }

      $pidfile->pid($PROCESS_ID);
      $pidfile->store;

DESCRIPTION

ATTRIBUTES

file

A string representing the full path to the file in which the PID is stored.

pid

An integer PID.

progname

The name of the program being run. The default is based on the contents of the $0 variable.

basedir

This is the directory into which the PID file will be stored. The default value is that returned by File::Spec tmpdir method. This will only be used when you have not specified a full path for the file attribute.

mode

This is the mode with which a new PID file will be created. The default is 0644.

SUBROUTINES/METHODS

init_pid

If the PID file already exists then the value stored in the file will be returned. Otherwise the value in the $$ variable will be returned.

clear_pid

This can be used to clear the value set for the pid attribute. This will force the PID file to be read again, or, if it does not exist, the value to be reset to that in the $$ variable.

init_pidfile

This returns the full path to the default location for the PID file. The filename is based on the progname resource with a .pid suffix. It will be in the directory specified in the basedir attribute.

store

This will write the value specified in the pid attribute into the file specified in the file attribute. You can control the mode of the file created via the mode attribute. If another process using this module already has the PID file open for writing then this method will fail immediately.

does_file_exist

Returns true/false to to show whether the file specified in the file attribute actually exists.

is_running

If the PID file exists then this will check if there is a process with this PID actually running and return true/false. The function first looks in the /proc directory, if that is not present then it will use the kill function with a signal of zero. If the PID file does not exist then this method returns undef.

remove

If the PID file exists then this will attempt to unlink it and return true/false to indicate success. If the file already does not exist the method just returns true.

DEPENDENCIES

This module is powered by Moose. It also requires MooseX::Getopt and " MooseX::Types".

SEE ALSO

PLATFORMS

This is the list of platforms on which we have tested this software. We expect this software to work on any Unix-like platform which is supported by Perl.

ScientificLinux5, Fedora13

BUGS AND LIMITATIONS

Please report any bugs or problems (or praise!) to bugs@lcfg.org, feedback and patches are also always very welcome.

AUTHOR

    Stephen Quinney <squinney@inf.ed.ac.uk>

LICENSE AND COPYRIGHT

    Copyright (C) 201O University of Edinburgh. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the terms of the GPL, version 2 or later.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 264:

L<> starts or ends with whitespace