Parano...ckfile(3pm)
π Paranoid::IO::Lockfile π
okay bestie, gather round, because this is Paranoid::IO::Lockfile from the User Contributed Perl Documentation set β yes it's a Perl module, yes it's a (3pm) man page, and yes it's lowkey essential if you've got a bunch of processes all trying to touch the same files at the same time like a group chat with no moderator. π«Ά
β¨ NAME β¨
Paranoid::IO::Lockfile β Paranoid Lockfile support π
π VERSION π
$Id: lib/Paranoid/IO/Lockfile.pm, 2.10 2022/03/08 00:01:04 acorliss Exp $
she's version 2.10, dated 2022/03/08, and her whole identity is right there in the $Id string, iconic honestly β¨
π¦ SYNOPSIS π¦
the vibe check, in code:
use Paranoid::IO::Lockfile;
use Fcntl qw(:flock); # only needed if you use plock in lieu
# of the other functions
$rv = plock($lockfile);
$rv = plock($lockfile, LOCK_SH | LOCK_NB);
$rv = plock($lockfile, LOCK_SH | LOCK_NB, $mode);
$rv = pexclock($lockfile);
$rv = pshlock($lockfile);
$rv = punlock($lockfile);
ngl thatuse Fcntl qw(:flock)line is only needed if you're callingplockinstead of the other functions. if you're just usingpexclock/pshlock/punlockyou can leave it in your drafts. π
πΈ DESCRIPTION πΈ
so basically this module hands you some convenience functions for using a lockfile to coordinate what a whole bunch of processes are doing at once β multi-process activities, organized, no chaos, no stepping on each other's toes. π
and likeβ¦ yeah it's basically just a thin wrapper around Paranoid::IO functions, but here's the thing β it eats the small tedium for you. you know the drill: doing the multiple opens necessary so that all processes are working off the same files, while dodging race conditions. she does that part so you don't have to. that's the whole service. that's the job. π«Ά
π§ IMPORT LISTS π§
by default, this module exports these symbols, no asking required:
plock pexclock pshlock punlock
and there are also these specialized import lists if you want to be specific about it:
allβ members:@defaults
(the original lays these out in a little table with a List column and a Members column, and all is the only row. just so you know nothing's hiding. π)
π SUBROUTINES/METHODS π
π₯ plock
$rv = plock($filename);
$rv = plock($filename, LOCK_EX);
$rv = plock($filename, LOCK_EX, 0666);
creates or opens the file you asked for while applying the lock condition. she is the moment. β¨
the deets, no cap:
- the lock type defaults to
LOCK_EXif you omit it - the file permissions default to
0660 - as always, umask applies (not me making the rules, that's just how it is π )
and here's the one scenario where you'd want to reach for plock instead of pexclock, etc. β you want to use plock in lieu of pexclock, etc. if you wish to perform non-blocking lock attempts. because here's the tea: all the convenience functions are blocking. every single one. so if non-blocking is the dream, plock is your girl. π€
π pexclock
$rv = pexclock($filename);
$rv = pexclock($filename, $mode);
a wrapper for plock($filename, LOCK_EX). that's it, that's the function, she's short and she knows exactly what she is. π
π pshlock
$rv = pshlock($filename);
$rv = pshlock($filename, $mode);
a wrapper for plock($filename, LOCK_SH). shared lock, shared vibes. π¦
β punlock
$rv = punlock($filename);
$rv = punlock($filename, $mode);
a wrapper for plock($filename, LOCK_UN).
okay IMPORTANT bestie, listen: this does not close the open file handle to the lock file. like, she unlocks but she does not tidy up. π for that you need to callParanoid::IO'spclosefunction. don't forget. i'm serious. π
π DEPENDENCIES π
she does not stand alone, she has a support system:
FcntlParanoidParanoid::DebugParanoid::IO
π BUGS AND LIMITATIONS π
(no content in the original β she simply has no notes at this time, and honestly? respect. π€)
π AUTHOR π
Arthur Corliss (corliss@digitalmages.com) β the icon, the legend, the author of this whole thing. π
π LICENSE AND COPYRIGHT π
okay so legally speaking: this software is free software. similar to Perl, you can redistribute it and/or modify it under the terms of either:
a) the GNU General Public License
<https://www.gnu.org/licenses/gpl-1.0.html> as published by the
Free Software Foundation <http://www.fsf.org/>; either version 1
<https://www.gnu.org/licenses/gpl-1.0.html>, or any later version
<https://www.gnu.org/licenses/license-list.html#GNUGPL>, or
b) the Artistic License 2.0
<https://opensource.org/licenses/Artistic-2.0>,
subject to the following additional term: no trademark rights to "Paranoid" have been or are conveyed under any of the above licenses. however, "Paranoid" may be used fairly to describe this unmodified software, in good faith, but not as a trademark. like, you can say it, you just can't claim it. periodt. π
(c) 2005 - 2020, Arthur Corliss (corliss@digitalmages.com) (tm) 2008 -
2020, Paranoid Inc. (www.paranoid.com)
and that's the whole page, bestie!! π this one shipped with perl v5.38.2 and the man page itself is dated 2024-03-07 β go forth, lock your files, avoid your race conditions, and remember to pclose your handles. mwah. πβ¨
π¦ where this page comes from
- debian trixie: libparanoid-perl 2.10-2 Β· other
- ubuntu resolute: libparanoid-perl 2.10-2 Β· other
- ubuntu stonking: libparanoid-perl 2.10-2 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms