File::Lockfile - create lockfile to prevent process simultaneous run


File-Lockfile documentation  | view source Contained in the File-Lockfile distribution.

Index


NAME

Top

File::Lockfile - create lockfile to prevent process simultaneous run

SYNOPSIS

Top

	use File::Lockfile;

	my $lockfile = File::Lockfile->new(
		'programname.pid',
		'/var/lock');

	...

	if ( my $pid = $lockfile->check ) {
		print "Seems that programname is already running with PID: $pid";
		exit;
	}

	$lockfile->write;

	...

	#somewhere in the end
	Lockfile->remove 
	or
	$lockfile->remove;




DESCRIPTION

Top

File::Lockfile provides convenient interface for creating process pid file. While text file creating is very simple procedure, module performs additional checks if process is really running.

METHODS

Top

new

Initializes module with required arguments.

check

Checks if lockfile exists, returns PID of running process. Actually, routine also checks if process with PID stored in lockfile actually running.

my $pid = $lockfile->check;

write

Writes lockfile. Use it somewhere after checking if file exists

remove

Removes lockfile. Manage it by yourself.

SEE ALSO

Top

File::PID File::PID::Quick

LICENSE AND COPYRIGHT

Top


File-Lockfile documentation  | view source Contained in the File-Lockfile distribution.