setlock(8)

πŸ“¦
version 0.76 Β· 2 versions
  • 0.76 Β· debian bookworm, debian trixie, nixpkgs unstable, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 1.11 Β· alpine 3.24
, in debian bookworm, debian trixie, nixpkgs unstable, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ‘‘ setlock(8) β€” the "run ur lil program but WITH a lock on it" manual πŸ’…

okay so bestie, this is a page from the System Manager's Manual, and it's all about setlock, which runs another program with a file locked. iconic behaviour honestly. let's get into it 🌸


✨ NAME ✨

setlock β€” runs another program with a file locked.

that's it. that's the whole vibe. it locks a file and runs ur child process. slay πŸŽ€


✨ SYNOPSIS ✨

setlock [ -nNxX ] fn child

✨ DESCRIPTION ✨

okay so here's the tea πŸ«–

fn is a single argument. child consists of one or more arguments.

setlock opens fn for writing (creating it if it does not exist, no cap), obtains an exclusive lock on it, and runs child. that's the whole thing, she's simple, she's effective πŸ’…

Normally the lock disappears when child exits. bye lock πŸ‘‹

Here's the complete story, fr fr: child is given a descriptor for a locked ofile pointing to the disk file named fn. The lock disappears when this ofile is

  • closed by all the processes that have descriptors for it or
  • explicitly unlocked.

so like… it's not just "when the process dies", it's about the descriptor. iykyk πŸ‘‘


✨ OPTIONS ✨

  • -n β€” No delay. If fn is locked by another process, setlock gives up. she's not waiting around for anybody, main character energy only πŸ’€
  • -N β€” (Default.) Delay. If fn is locked by another process, setlock waits until it can obtain a new lock. patient queen 🧚
  • -x β€” If fn cannot be opened (or created) or locked, setlock exits zero. yes really, zero. wild but true 😭
  • -X β€” (Default.) If fn cannot be opened (or created) or locked, setlock prints an error message and exits nonzero. the drama of it all πŸ’…
lowkey important: -N and -X are the defaults, so if u just run it plain, u get the waiting + the error message combo. periodt.

✨ SEE ALSO ✨

go read these too bestie, they're all part of the same friend group πŸ’–

supervise(8), svc(8), svok(8), svstat(8), svscanboot(8), svscan(8), readproctitle(8), fghack(8), pgrphack(8), multilog(8), tai64n(8), tai64nlocal(8), setuidgid(8), envuidgid(8), envdir(8), softlimit(8)

http://cr.yp.to/daemontools.html


and that's the whole page, bestie πŸ¦‹ this lil cutie lives in the System Manager's Manual under the name setlock(8) β€” same name up top, same name at the bottom, symmetric queen πŸ’œ k bye, go lock something responsibly ✨

πŸ“¦ where this page comes from