s6-fdholder-retrieve.html (3607B)
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-fdholder-retrieve program</title> 7 <meta name="Description" content="s6: the s6-fdholder-retrieve program" /> 8 <meta name="Keywords" content="s6 s6-fdholder fd-holding fd-holder fd retrieval unix socket activation" /> 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 <tt>s6-fdholder-retrieve</tt> program </h1> 20 21 <p> 22 <tt>s6-fdholder-retrieve</tt> connects to a 23 <a href="s6-fdholderd.html">fd-holding daemon</a> listening on a 24 Unix domain socket, and retrieves a file descriptor from this 25 daemon, then executes a program with this file descriptor as the 26 program's standard input. 27 </p> 28 29 <h2> Interface </h2> 30 31 <pre> 32 s6-fdholder-retrieve [ -D ] [ -t <em>timeout</em> ] <em>path</em> <em>id</em> <em>prog...</em> 33 </pre> 34 35 <ul> 36 <li> <tt>s6-fdholder-retrieve</tt> connects to a 37 <a href="s6-fdholderd.html">s6-fdholderd</a> server process listening on 38 <em>path</em>. </li> 39 <li> It attempts to retrieve a copy of the file descriptor that has been 40 stored into that daemon under identifier <em>id</em>. 41 <li> It then executes into <em>prog...</em>, with the retrieved 42 file descriptor as standard input. </li> 43 </ul> 44 45 <h2> Options </h2> 46 47 <ul> 48 <li> <tt>-D</tt> : delete the file descriptor from the server's 49 storage after retrieval. This option requires writing rights over the 50 given identifier as well as reading rights: check the server's 51 <a href="s6-fdholderd.html#configuration">configuration</a>. </li> 52 <li> <tt>-t <em>timeout</em></tt> : if the operation cannot be 53 processed in <em>timeout</em> milliseconds, then fail with an error message. 54 Communications with the server should be near-instant, so this option is 55 only here to protect users against programming errors (connecting to the 56 wrong socket, for instance). </li> 57 </ul> 58 59 <h2> Exit codes </h2> 60 61 <ul> 62 <li> On success, the program doesn't exit; instead, it execs into <em>prog...</em>. </li> 63 <li> 1: the server denied the operation. The meaning of the error messages 64 is explained <a href="s6-fdholder-errorcodes.html">here</a>. </li> 65 <li> 100: wrong usage. </li> 66 <li> 111: system call failed - this includes attempting to connect to a 67 nonexistent socket, or one where no <a href="s6-fdholderd.html">s6-fdholderd</a> 68 daemon is listening. </li> 69 </ul> 70 71 <h2> Usage example </h2> 72 73 <pre> 74 s6-fdholder-retrieve /service/fdholderd/s MYSOCKET s6-ipcserverd cat 75 </pre> 76 77 <p> 78 will retrieve a file descriptor stored under the MYSOCKET identifier in 79 the s6-fdholderd daemon listening on the <tt>/service/fdholderd/s</tt> 80 socket, and execute into <tt>s6-ipcserverd cat</tt> with this file 81 descriptor as stdin. In this case, if MYSOCKET referred to a Unix domain 82 socket, <a href="s6-ipcserverd.html">s6-ipcserverd</a> will then accept 83 client connections on it and spawn a <tt>cat</tt> program for every 84 connection. 85 </p> 86 87 <h2> Notes </h2> 88 89 <ul> 90 <li> To execute <em>prog</em> with the newly retrieved file descriptor 91 as number <em>n</em> while preserving stdin, use the following construct: 92 <tt>fdmove <em>n</em> 0 s6-fdholder-retrieve <em>path</em> <em>id</em> 93 <a href="//skarnet.org/software/execline/fdswap.html">fdswap</a> 94 0 <em>n</em> <em>prog...</em></tt>. </li> 95 </ul> 96 97 </body> 98 </html>