blob: 91e2fcc3d6c77ba22f0d66a3012c6d963bd58ee9 (
plain)
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> ] [ -d <em>fd</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> : nonblocking lock. If s6-setlock cannot acquire the lock, it will
exit 1 immediately. </li>
<li> <tt>-N</tt> : blocking lock. s6-setlock will wait until it can acquire the lock.
This is the default. </li>
<li> <tt>-t <em>timeout</em></tt> : timed lock. If s6-setlock cannot acquire
the lock after <em>timeout</em> milliseconds, it will exit 1. </li>
<li> <tt>-r</tt> : 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> : exclusive lock. This is the default. </li>
<li> <tt>-d <em>fd</em></tt> : make the lock visible in <em>prog</em>
on file descriptor <em>fd</em>. </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; 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
<em>prog</em>, that's where the <tt>-d</tt> option comes in. </li>
</ul>
</body>
</html>
|