NAME

Proc::PID_File - check whether a self process is already running

SYNOPSIS

use Proc::PID_File;

$Pid_File = Proc::PID_File->new(path=>"/var/run/mydaemon.pid");
if (!$Pid_File->init)  { die "Can't open/create pid file: $!" }
if ($Pid_File->active) { die "mydaemon is already running" }

# go ahead, daemonize...

DESCRIPTION

A pid file is a file that contain, guess what, pid. Pids are written down to files so that:

  • a program can know whether an instance of itself is currently running

  • other processes can know the pid of a running program

This module can be used so that your script can do the former.

If a pid file is created by the init() method, it will be automatically deleted when the object is destroyed (the forked child's object will not delete the pid file -- since 0.03).

AUTHOR

Copyright (C) 2000-1, Steven Haryanto <steven@haryan.to>. All rights reserved.

This module is free software; you may redistribute it and/or modify it under the same terms as Perl itself.

HISTORY

000731 - first hack

010522 - incorporate a couple of suggestions. thanks to HASANT and Brad Hilton.