summary refs log tree commit diff
path: root/doc/s6-fdholder-getdump.html
blob: 6d49f2cddcaa7b8588e471f6ea6d3b70a52f8c7e (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<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-fdholder-getdump program</title>
    <meta name="Description" content="s6: the s6-fdholder-getdump program" />
    <meta name="Keywords" content="s6 s6-fdholder fd-holding fd-holder fd dump retrieval unix socket activation" />
    <!-- <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 <tt>s6-fdholder-getdump</tt> program </h1>

<p>
<tt>s6-fdholder-getdump</tt> connects to a
<a href="s6-fdholderd.html">fd-holding daemon</a> listening on a
Unix domain socket, and retrieves its entire state: file descriptors with
their identifiers and expiration dates. It then executes a program with
those file descriptors still open, and the state stored in the
environment.
</p>

<h2> Interface </h2>

<pre>
     s6-fdholder-getdump [ -t <em>timeout</em> ] <em>path</em> <em>prog...</em>
</pre>

<ul>
 <li> <tt>s6-fdholder-getdump</tt> connects to a
<a href="s6-fdholderd.html">s6-fdholderd</a> server process listening on
<em>path</em>. </li>
 <li> It retrieves a copy of the whole set of file descriptors
stored in this daemon, including their identifiers and expiration dates. </li>
 <li> It then executes into <em>prog...</em> with the additional open descriptors
and the additional environment variables. </li>
</ul>

<h2> Options </h2>

<ul>
 <li> <tt>-t&nbsp;<em>timeout</em></tt>&nbsp;: if the operation cannot be
processed in <em>timeout</em> milliseconds, then fail with an error message.
Communications with the server should be near-instant, so this option is
only here to protect users against programming errors (connecting to the
wrong socket, for instance). </li>
</ul>

<h2> Exit codes </h2>

<ul>
 <li> On success, the program doesn't exit; instead, it execs into <em>prog...</em>. </li>
 <li> 1: the server denied the operation. The meaning of the error messages
is explained <a href="s6-fdholder-errorcodes.html">here</a>. </li>
 <li> 100: wrong usage. </li>
 <li> 111: system call failed - this includes attempting to connect to a
nonexistent socket, or one where no <a href="s6-fdholderd.html">s6-fdholderd</a>
daemon is listening. </li>
</ul>

<h2> Environment format </h2>

<p>
 <em>prog...</em> is executed with the following environment variables
set:
</p>

<ul>
 <li> <tt>S6_FD#</tt>&nbsp;: contains the number <em>n</em> of file
descriptors retrieved from the server. </li>
 <li> Then, for every <em>i</em> between 0 and <em>n</em>-1 inclusive:
 <ul>
  <li> <tt>S6_FD_<em>i</em></tt>&nbsp;: contains the number of the <em>i</em>th
open file descriptor. </li>
  <li> <tt>S6_FDID_<em>i</em></tt>&nbsp;: contains the identifier of the
<em>i</em>th open file descriptor. </li>
  <li> <tt>S6_FDLIMIT_<em>i</em></tt>&nbsp;: contains the expiration date of
the <em>i</em>th open file descriptor, if applicable. This date is stored in
<a href="https://cr.yp.to/libtai/tai64.html#tai64n">external TAI64N
format</a>.<br />
If the file descriptor is not supposed to expire, this environment variable
is not defined. </li>
 </ul> </li>
</ul>

<h2> Usage example </h2>

<pre>
   s6-fdholder-getdump /service/fdholderd/s s6-fdholder-setdump /service/fdholderd-2/s
</pre>

<p>
will get the state of the s6-fdholderd daemon listening on the <tt>/service/fdholderd/s</tt>
socket, and transmit it to the other s6-fdholderd daemon listening on the
<tt>/service/fdholderd-2/s</tt> socket. Note that in this precise case,
the <a href="s6-fdholder-transferdump.html">s6-fdholder-transferdump</a>
program does the same thing more efficiently.
</p>

<h2> Notes </h2>

<ul>
 <li> Getting the whole state of an s6-fdholderd daemon requires specific
privileges. Make sure you properly
<a href="s6-fdholderd.html#configuration">configure the s6-fdholderd
access rights</a> so your client can perform that operation. </li>
</ul>

</body>
</html>