Debian Codegraph @

README

raw
1 NAME
2 File::Flock - file locking with flock
3
4 SYNOPSIS
5 use File::Flock;
6
7 lock($filename);
8
9 lock($filename, 'shared');
10
11 lock($filename, undef, 'nonblocking');
12
13 lock($filename, 'shared', 'nonblocking');
14
15 unlock($filename);
16
17 lock_rename($oldfilename, $newfilename)
18
19 my $lock = new File::Flock '/somefile';
20
21 $lock->unlock();
22
23 $lock->lock_rename('/new/file');
24
25 forget_locks();
26
27 DESCRIPTION
28 Lock files using the flock() call. If the file to be locked does not
29 exist, then the file is created. If the file was created then it will be
30 removed when it is unlocked assuming it's still an empty file.
31
32 Locks can be created by new'ing a File::Flock object. Such locks are
33 automatically removed when the object goes out of scope. The unlock()
34 method may also be used.
35
36 lock_rename() is used to tell File::Flock when a file has been renamed
37 (and thus the internal locking data that is stored based on the filename
38 should be moved to a new name). unlock() the new name rather than the
39 original name.
40
41 Locks are released on process exit when the process that created the
42 lock exits. Subprocesses that exit do not remove locks. Use
43 forget_locks() or POSIX::_exit() to prevent unlocking on process exit.
44
45 SEE ALSO
46 See File::Flock::Subprocess for a variant that uses a subprocess to hold
47 the locks so that the locks survive when the parent process forks. See
48 File::Flock::Forking for a way to automatically choose between
49 File::Flock and File::Flock::Subprocess.
50
51 LICENSE
52 Copyright (C) 1996-2012 David Muir Sharnoff <[email protected]>
53 Copyright (C) 2013 Google, Inc. This module may be used/copied/etc on
54 the same terms as Perl itself.
55
56 PACKAGERS
57 File::Flock is packaged for Fedora by Emmanuel Seyman
58 <[email protected]>.
59