File::Flock(3pm)
πΈ NAME πΈ
okay bestie, welcome to File::Flock(3pm) from the User Contributed Perl Documentation corner π. This module is literally file locking with flock β and that's the whole name, no cap. slay.
β¨ SYNOPSIS β¨
use File::Flock;
lock($filename);
lock($filename, 'shared');
lock($filename, undef, 'nonblocking');
lock($filename, 'shared', 'nonblocking');
unlock($filename);
lock_rename($oldfilename, $newfilename)
my $lock = new File::Flock '/somefile';
$lock->unlock();
$lock->lock_rename('/new/file');
forget_locks();
π« DESCRIPTION π«
okay so the whole vibe is: lock files using the flock() call. If the file to be locked does not exist, then the file is created. And if the file was created, it will be removed when it is unlocked β assuming it's still an empty file. that last bit matters, fr fr.
Locks can be created by new'ing a File::Flock object. Such locks are automatically removed when the object goes out of scope. The unlock() method may also be used. iconic behavior.
lock_rename() is used to tell File::Flock when a file has been renamed β and thus the internal locking data that is stored based on the filename should be moved to a new name. Then unlock() the new name rather than the original name. iykyk.
Locks are released on process exit when the process that created the lock exits.
π¨ subprocess check, bestie: subprocesses that exit do not remove locks.
Use forget_locks() or POSIX::_exit() to prevent unlocking on process exit. periodt.
π SEE ALSO π
File::Flock::Subprocessβ a variant that uses a subprocess to hold the locks so that the locks survive when the parent process forks.File::Flock::Forkingβ a way to automatically choose betweenFile::FlockandFile::Flock::Subprocess.
π LICENSE π
- Copyright (C) 1996-2012 David Muir Sharnoff
<cpan@dave.sharnoff.org> - Copyright (C) 2013 Google, Inc.
This module may be used/copied/etc on the same terms as Perl itself. periodt π
π¦ PACKAGERS π¦
File::Flock is packaged for Fedora by Emmanuel Seyman <emmanuel.seyman@club-internet.fr>. cute.
okay that's the whole page bestie π sign-off vibes: this is the File::Flock(3pm) manual, from perl v5.42.0, dated 2015-04-17. mwah π
π¦ where this page comes from
- opensuse-leap 16.0: perl-File-Flock 2014.01-bp160.1.11 Β· Artistic-1.0 or GPL-1.0+
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms