S6-SETLOCK(8)

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
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....

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.

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.

SEE ALSO
s6lockd(8), s6lockd-helper(8)

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)