about summary refs log tree commit diff
path: root/doc/s6-setlock.html
blob: c2e8fbfb13e176e666d260a797ecef3a4aaca991 (plain) (blame)
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
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta http-equiv="Content-Language" content="en" />
    <title>s6: the s6-setlock program</title>
    <meta name="Description" content="s6: the s6-setlock program" />
    <meta name="Keywords" content="s6 command s6-setlock lock program" />
    <!-- <link rel="stylesheet" type="text/css" href="//skarnet.org/default.css" /> -->
  </head>
<body>

<p>
<a href="index.html">s6</a><br />
<a href="//skarnet.org/software/">Software</a><br />
<a href="//skarnet.org/">skarnet.org</a>
</p>

<h1> The s6-setlock program </h1>

<p>
s6-setlock takes a lock on a file, then executes into another program.
</p>

<h2> Interface </h2>

<pre>
     s6-setlock [ -n | -N | -t <em>timeout</em> ] [ -r | -w ] <em>file</em> <em>prog...</em>
</pre>

<ul>
 <li> s6-setlock creates <em>file</em> if it does not exist and opens it for writing. </li>
 <li> It locks <em>file</em>. If it cannot take the lock for any reason, it exits 1. </li>
 <li> It executes into <em>prog...</em>. </li>
</ul>

<h2> Options </h2>

<ul>
 <li> <tt>-n</tt>&nbsp;: nonblocking lock. If s6-setlock cannot acquire the lock, it will
exit 1 immediately. </li>
 <li> <tt>-N</tt>&nbsp;: blocking lock. s6-setlock will wait until it can acquire the lock.
This is the default. </li>
 <li> <tt>-t&nbsp;<em>timeout</em></tt>&nbsp;: timed lock. If s6-setlock cannot acquire
the lock after <em>timeout</em> milliseconds, it will exit 1. </li>
 <li> <tt>-r</tt>&nbsp;: shared lock. Other shared locks on the same file will not prevent
the lock from being acquired (but an exclusive lock will). </li>
 <li> <tt>-w</tt>&nbsp;: exclusive lock. This is the default. </li>
</ul>

<h2> Notes </h2>

<ul>
 <li> s6-setlock leaks an open file descriptor into the <em>prog</em>
execution. This is intended: the fd holds the lock, which is released
when <em>prog</em> exits. <em>prog</em> must not touch fds it does not
know about. </li>
 <li> If the timed lock option is chosen, s6-setlock does not acquire the lock
itself. Instead, it spawns a <a href="libs6/s6lockd-helper.html">s6lockd-helper</a>
process that acquires the lock while s6-setlock controls the timeout; the
s6lockd-helper process then holds the lock and lives as long as
<em>prog</em>. </li>
</ul>

</body>
</html>