NAME

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

SYNOPSIS

use File::Lockfile;

my $lockfile = File::Lockfile->new(
	key => 'programname',
	dir => '/var/lock',
	pattern => '%k.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

File::Lockfile provides convenient interface for creating process lock file. While text file creating is very simple procedure, module performs additional checks if process is really running. Additionally, module can install $SIG{__DIE__} handler to remove lockfile if program exited unexpectedly. It does that, by appending lockfile removing procedure to existing handler.

METHODS

new

Initializes module with required arguments.

check

remove

install_die_handler

SEE ALSO

File::PID File::PID::Quick

LICENSE AND COPYRIGHT

Copyright 2008, Sergey Sinkovskiy <glorybox@cpan.org>

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