PkgForge::PidFile - A class to provide simple PID file handling
This documentation refers to PkgForge::PidFile version 1.1.10
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;
A string representing the full path to the file in which the PID is stored.
An integer PID.
The name of the program being run. The default is based on the contents of the $0 variable.
$0
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.
File::Spec
tmpdir
file
This is the mode with which a new PID file will be created. The default is 0644.
0644
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.
$$
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.
pid
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.
progname
.pid
basedir
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.
mode
Returns true/false to to show whether the file specified in the file attribute actually exists.
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.
/proc
kill
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.
This module is powered by Moose. It also requires MooseX::Getopt and " MooseX::Types".
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
Please report any bugs or problems (or praise!) to bugs@lcfg.org, feedback and patches are also always very welcome.
Stephen Quinney <squinney@inf.ed.ac.uk>
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:
L<> starts or ends with whitespace
To install PkgForge::Queue, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PkgForge::Queue
CPAN shell
perl -MCPAN -e shell install PkgForge::Queue
For more information on module installation, please visit the detailed CPAN module installation guide.