s6-setlock.html (2395B)
1 <html> 2 <head> 3 <meta name="viewport" content="width=device-width, initial-scale=1.0" /> 4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 5 <meta http-equiv="Content-Language" content="en" /> 6 <title>s6: the s6-setlock program</title> 7 <meta name="Description" content="s6: the s6-setlock program" /> 8 <meta name="Keywords" content="s6 command s6-setlock lock program" /> 9 <!-- <link rel="stylesheet" type="text/css" href="//skarnet.org/default.css" /> --> 10 </head> 11 <body> 12 13 <p> 14 <a href="index.html">s6</a><br /> 15 <a href="//skarnet.org/software/">Software</a><br /> 16 <a href="//skarnet.org/">skarnet.org</a> 17 </p> 18 19 <h1> The s6-setlock program </h1> 20 21 <p> 22 s6-setlock takes a lock on a file, then executes into another program. 23 </p> 24 25 <h2> Interface </h2> 26 27 <pre> 28 s6-setlock [ -n | -N ] [ -t <em>timeout</em> ] [ -d <em>fd</em> ] [ -r | -w ] <em>file</em> <em>prog...</em> 29 </pre> 30 31 <ul> 32 <li> s6-setlock creates <em>file</em> if it does not exist and opens it for writing. </li> 33 <li> It locks <em>file</em>. If it cannot take the lock for any reason, it exits 1. </li> 34 <li> It executes into <em>prog...</em>. </li> 35 </ul> 36 37 <h2> Options </h2> 38 39 <ul> 40 <li> <tt>-n</tt> : nonblocking lock. If s6-setlock cannot acquire the lock, it will 41 exit 1 immediately. </li> 42 <li> <tt>-N</tt> : blocking lock. s6-setlock will wait until it can acquire the lock. 43 This is the default. </li> 44 <li> <tt>-t <em>timeout</em></tt> : timed lock. If s6-setlock cannot acquire 45 the lock after <em>timeout</em> milliseconds, it will exit 1. </li> 46 <li> <tt>-r</tt> : shared lock. Other shared locks on the same file will not prevent 47 the lock from being acquired (but an exclusive lock will). </li> 48 <li> <tt>-w</tt> : exclusive lock. This is the default. </li> 49 <li> <tt>-d <em>fd</em></tt> : make the lock visible in <em>prog</em> 50 on file descriptor <em>fd</em>. </li> 51 </ul> 52 53 <h2> Notes </h2> 54 55 <ul> 56 <li> 57 s6-setlock leaks an open file descriptor into the <em>prog</em> 58 execution. This is intended: the fd holds the lock, which is released 59 when <em>prog</em> exits. <em>prog</em> must not touch fds it does not 60 know about; by default it has no need to know the descriptor that holds 61 the lock. But if you need to officialize the presence of the lock in 62 <em>prog</em>, that's where the <tt>-d</tt> option comes in. </li> 63 </ul> 64 65 </body> 66 </html>