File::...process(3pm)

okay bestie, welcome to File::...process(3pm) β€” the page from User Contributed Perl Documentation. She's a little Perl module with big main-character energy, and we're gonna get you fluent in her whole deal. πŸ’…βœ¨

πŸ’– NAME πŸ’–

File::Flock::Subprocess β€” file locking with flock in a subprocess. That's the whole vibe: flock locking, but the locking lives in a subprocess. πŸ¦‹

✨ SYNOPSIS ✨

Here's the demo reel, exactly as written β€” no cap, every call is here:

use File::Flock::Subprocess;

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();

That's use File::Flock::Subprocess;, then all the locking, unlocking, rename, and forget-locks moves. πŸŽ€

🌸 DESCRIPTION 🌸

okay so the tea is: this module is a wrapper around File::Flock that starts a subprocess and does the locking in the subprocess with File::Flock. The whole point? To handle operating systems (eg: Solaris) that do not retain locks across a call to fork(). Literally iconic problem-solving. πŸ’–

Here's the part to keep on your radar: the sub-process for this is created with fork() when File::Flock::Subprocess is compiled. The author tried to minimize the side-effects of calling fork() by calling it early and by using POSIX::_exit() to quit, but it is still worth being aware of. So yeah β€” lowkey important. The author suggests loading File::Flock::Subprocess early. 🫢

Want it to auto-detect when this is needed? Use File::Flock::Forking. For the details of the API, read the docs for File::Flock. iykyk. πŸ“š

🫢 ERRATA 🫢

Any errors reported by the locking proxy that File::Flock::Subprocess starts will be reported as "Compilation Failed" errors because the proxy is started in a BEGIN{} block. So if you see that, don't panic β€” it's the proxy being a little extra at compile time. πŸ’€

πŸ‘‘ LICENSE πŸ‘‘

Copyright (C) 2013 Google, Inc. This module may be used/copied/etc on the same terms as Perl itself. That's the legal tea, bestie β€” short and sweet. πŸ‘‘


Catch you later! This page is from perl v5.42.0, dated 2015-04-17, and its manual name is File::...process(3pm). Byeee πŸ’œπŸŒˆ

πŸ“¦ where this page comes from