lockfile-progs(1)

πŸ’– lockfile-progs πŸ’–

okay bestie, welcome to lockfile-progs β€” aka the Lockfile programs, the little command-line crew that locks and unlocks your files and mailboxes safely (via liblockfile). no cap, this is the whole vibe. πŸŽ€


✨ NAME ✨

lockfile-progs β€” command-line programs to safely lock and unlock files and mailboxes (via liblockfile).


🌸 SYNOPSIS 🌸

mail-lock [--use-pid] [--retry retry-count]
mail-unlock
mail-touchlock [--oneshot]

lockfile-create [--use-pid] [--retry retry-count] [--lock-name] filename
lockfile-remove [--lock-name] filename
lockfile-touch [--oneshot] [--lock-name] filename
lockfile-check [--use-pid] [--lock-name] filename

πŸ¦‹ DESCRIPTION πŸ¦‹

so lockfile-progs hands you a whole set of programs that lock and unlock mailboxes and files safely (via liblockfile). it's giving "responsible friend who holds your keys." πŸ”‘

  • mail-lock β€” lock the current user's mailbox
  • mail-unlock β€” unlock the current user's mailbox
  • mail-touchlock β€” touch the lock on the current user's mailbox
  • lockfile-create β€” lock a given file
  • lockfile-remove β€” remove the lock on a given file
  • lockfile-touch β€” touch the lock on a given file
  • lockfile-check β€” check the lock on a given file

by default, the filename argument refers to the name of the file to be locked, and the name of the lockfile will be filename .lock. but β€” if the --lock-name argument is specified, then filename will be taken as the name of the lockfile itself. plot twist, but a cute one. πŸ’…

each of the mail locking commands attempts to lock /var/spool/mail/<user>, where <user> is the name associated with the effective user ID, as determined by via geteuid(2).

once a file is locked, the lock must be touched at least once every five minutes or the lock will be considered stale, and subsequent lock attempts will succeed. lowkey important!! also see the --use-pid option and the lockfile_create(3) manpage.

the lockfile-check command tests whether or not a valid lock already exists. vibe check for locks, fr fr. ✨


πŸ’… OPTIONS πŸ’…

  • --version β€” report the version to standard output and exit. bye bestie πŸ‘‹
  • -q, --quiet β€” suppress any output. success or failure will only be indicated by the exit status. silent but iconic. 🀫
  • -v, --verbose β€” enable diagnostic output. tell me everything, i'm obsessed. πŸ‘€
  • -l, --lock-name β€” do not append .lock to the filename. this option applies to lockfile-create, lockfile-remove, lockfile-touch, or lockfile-check.
  • -p, --use-pid β€” write the parent process id (PPID) to the lockfile whenever a lockfile is created, and use that pid when checking a lock's validity. see the lockfile_create(3) manpage for more information. this option applies to lockfile-create and lockfile-check.
NOTE: this option will not work correctly between machines sharing a filesystem. πŸ’€ do not do the thing.
  • -o, --oneshot β€” touch the lock and exit immediately. this option applies to lockfile-touch and mail-touchlock. when not provided, these commands will run forever, touching the lock once every minute until killed. main character energy that never leaves the party. 😭
  • -r retry-count, --retry retry-count β€” try to lock filename retry-count times before giving up. each attempt will be delayed a bit longer than the last (in 5 second increments) until reaching a maximum delay of one minute between retries. if retry-count is unspecified, the default is 9 which will give up after 225 seconds if all 9 lock attempts fail.

πŸ“ EXAMPLES πŸ“

locking a file during a lengthy process:

lockfile-create /some/file
lockfile-touch /some/file &
# Save the PID of the lockfile-touch process
BADGER="$!"
do-something-important-with /some/file
kill "${BADGER}"
lockfile-remove /some/file

the variable is literally named BADGER. we love to see it. 🦑✨


🌈 EXIT STATUS 🌈

  • 0 β€” for lockfile-check this indicates that a valid lock exists, otherwise it just indicates successful program execution. slay. πŸ‘‘
  • Not 0 β€” for lockfile-check a non-zero exit status indicates that the specified lock does not exist or is not valid. for other programs it indicates that some problem was encountered. not slay. 😭

🫢 SEE ALSO 🫢


🧚 AUTHOR 🧚

written by Rob Browning <rlb@defaultvalue.org>


okay that's the whole page, bestie!! this one's version 0.2.0build1 and it was dated 2025-12-06 β€” iconic numbers, no notes. now go lock something safely and touch it every five minutes. mwah. πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from