forked from flexibeast/s6-man-pages
-
Notifications
You must be signed in to change notification settings - Fork 0
/
s6-setlock.1
82 lines (82 loc) · 1.6 KB
/
s6-setlock.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
.Dd September 10, 2020
.Dt S6-SETLOCK 1
.Os
.Sh NAME
.Nm s6-setlock
.Nd take a lock on a file, then execute into another program
.Sh SYNOPSIS
.Nm
.Op Fl n | N | t Ar timeout
.Op Fl r | w
.Ar file
.Ar prog...
.Sh DESCRIPTION
.Nm
creates
.Ar file
if it does not exist and opens it for writing.
.Pp
It locks
.Ar file .
If it cannot take the lock for any reason, it exits 1.
.Pp
It executes into
.Ar prog... .
.Pp
.Nm
leaks an open file descriptor into the
.Ar prog
execution.
This is intended: the fd holds the lock, which is released when
.Ar prog
exits.
.Ar prog
must not touch fds it does not know about.
.Pp
If the timed lock option is chosen,
.Nm
does not acquire the lock itself.
Instead, it spawns an
.Xr s6lockd-helper 1
process that acquires the lock while
.Nm
controls the timeout; the
.Xr s6lockd-helper 1
process then holds the lock and lives as long as
.Ar prog .
.Sh OPTIONS
.Bl -tag -width x
.It Fl n
Nonblocking lock.
If
.Nm
cannot acquire the lock, it will exit 1 immediately.
.It Fl N
Blocking lock.
.Nm
will wait until it can acquire the lock.
This is the default.
.It Fl t Ar timeout
Timed lock.
If
.Nm
cannot acquire the lock after
.Ar timeout
milliseconds, it will exit 1.
.It Fl r
Shared lock.
Other shared locks on the same file will not prevent the lock from
being acquired (but an exclusive lock will).
.It Fl w
Exclusive lock.
This is the default.
.El
.Sh SEE ALSO
.Xr s6-s6lockd 1 ,
.Xr s6lockd-helper 1
.Pp
This man page is ported from the authoritative documentation at:
.Lk https://skarnet.org/software/s6/s6-setlock.html
.Sh AUTHORS
.An Laurent Bercot
.An Alexis Ao Mt [email protected] Ac (man page port)