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 between File::Flock and File::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