aboutsummaryrefslogtreecommitdiffstats
s6: the s6-setlock program

s6
Software
skarnet.org

The s6-setlock program

s6-setlock takes a lock on a file, then executes into another program.

Interface

     s6-setlock [ -n | -N ] [ -t timeout ] [ -d fd ] [ -r | -w ] file prog...
  • s6-setlock creates file if it does not exist and opens it for writing.
  • It locks file. If it cannot take the lock for any reason, it exits 1.
  • It executes into prog....

Options

  • -n : nonblocking lock. If s6-setlock cannot acquire the lock, it will exit 1 immediately.
  • -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 will exit 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.

Notes

  • s6-setlock leaks an open file descriptor into the prog execution. This is intended: the fd holds the lock, which is released when prog exits. prog must not touch fds it does not know about; by default it has no need to know the descriptor that holds the lock. But if you need to officialize the presence of the lock in prog, that's where the -d option comes in.