S6-SETLOCK(8)

πŸ“¦ version 2.15.1.0, in nixpkgs unstable

πŸ’… S6-SETLOCK πŸ’…

okay so this is from the System Manager's Manual bestie β€” it's s6-setlock, and it's literally the "grab a lock then become somebody else" tool ✨


🌸 NAME 🌸

s6-setlock β€” take a lock on a file, then execute into another program 🫢


πŸŽ€ SYNOPSIS πŸŽ€

s6-setlock [-n | -N] [-t timeout] [-d fd] [-r | -w] file prog...

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the whole vibe: s6-setlock creates file if it doesn't exist yet, and opens it for writing. πŸ”₯

Then it locks file. And if it can't take the lock β€” for any reason β€” it exits 1. no negotiation, no drama, just bye πŸ’€

Then it executes into prog.... like, actually becomes it. main character energy πŸ‘‘

Now here's the part that's giving intentional-and-also-kinda-slay: s6-setlock leaks an open file descriptor into the prog execution. and that is on purpose, bestie β€” the fd is what's holding the lock, and the lock gets released when prog exits. πŸŽ€

prog must not touch fds it doesn't know about. by default it has no need to know about the descriptor that holds the lock. but if you need to officialize the presence of the lock in prog β€” that's exactly where the -d option comes in, iykyk πŸ’…

✨ OPTIONS ✨

  • -n β€” nonblocking lock. if s6-setlock cannot acquire the lock, it exits 1 immediately. no waiting, we're impatient, we have places to be πŸƒβ€β™€οΈ
  • -N β€” blocking lock. s6-setlock will wait until it can acquire the lock. this is the default 🫢
  • -t timeout β€” timed lock. if s6-setlock cannot acquire the lock after timeout milliseconds, it exits 1 ⏳
  • -r β€” shared lock. other shared locks on the same file will not prevent the lock from being acquired (but an exclusive lock will) πŸ’–
  • -w β€” exclusive lock. this is the default πŸ”’
  • -d fd β€” make the lock visible in prog on file descriptor fd πŸ‘€

🐚 SEE ALSO 🐚

This man page is ported from the authoritative documentation at: https://skarnet.org/software/s6/s6-setlock.html 🌈


πŸ’œ AUTHORS πŸ’œ

  • Laurent Bercot
  • Alexis <flexibeast@gmail.com> (man page port)

and that's the whole thing, bestie πŸŽ€ this Debian build is dated November 7, 2023, so if you're reading it in the future β€” hi, hope your locks are all uncontended πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from