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

NAME

 File::Flock::Subprocess - file locking with flock in a subprocess

SYNOPSIS

 use File::Flock::Subprocess;

 lock($filename);

 lock($filename, 'shared');

 lock($filename, undef, 'nonblocking');

 lock($filename, 'shared', 'nonblocking');

 unlock($filename);

 my $lock = new File::Flock '/somefile';

 lock_rename($oldfilename, $newfilename)

DESCRIPTION

This is a wrapper around File::Flock that starts a subprocess and does the lcoking in the subprocess with File::Flock. The purpose of this is to handle strange operating systems (Solaris) that do not retain locks across a call to fork().

This is a gross hack. It exists because Soloaris doesn't preserve locks across a fork(). The implementation is a hack.

The sub-process for this is created with fork() when File::Flock::Subprocess is compiled. I've tried to minimize the side-effects calling fork() by doing calling it early and by using POSIX::_exit() to quit but it is still worth being aware of. I suggest loading File::Flock::Subprocess early.

ERRATA

Any errors reported by the locking proxy File::Flock::Subprocess starts will be reported as "Compilation Failed" errors because the proxy is started in a BEGIN{} block.

LICENSE

Copyright (C) 2013 Google, Inc. This module may be used/copied/etc on the same terms as Perl itself.