commit 49f1f9efe1874449303ca8c95a35a7b2bd4e13a0
parent 96d70608d25da81038ac3bfb5273852f33e27504
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date: Thu, 25 Jun 2015 19:17:43 +0000
- doc fixes (changed mentions of s6-notifywhenup)
- s6-svc -X
- rc for 2.1.6.0
Diffstat:
9 files changed, 88 insertions(+), 29 deletions(-)
diff --git a/doc/index.html b/doc/index.html
@@ -101,7 +101,7 @@ library. </li>
<h3> Download </h3>
<ul>
- <li> The current released version of s6 is <a href="s6-2.1.5.0.tar.gz">2.1.5.0</a>. </li>
+ <li> The current released version of s6 is <a href="s6-2.1.6.0.tar.gz">2.1.6.0</a>. </li>
<li> Alternatively, you can checkout a copy of the s6 git repository:
<pre> git clone git://git.skarnet.org/s6 </pre> </li>
<li> There's also a
diff --git a/doc/s6-fdholderd.html b/doc/s6-fdholderd.html
@@ -65,10 +65,9 @@ state </li>
<li> <tt>-1</tt> : write a newline to stdout, and close stdout,
right before entering the client-accepting loop.
If stdout is suitably redirected, this can be used by monitoring
-programs to check when the server is accepting connections.
-The <a href="s6-notifywhenup.html">s6-notifywhenup</a>
-program can be used before the s6-ipcserver
-invocation to notify listeners when the server is ready. </li>
+programs to check when the server is accepting connections. See
+The <a href="notifywhenup.html">this page</a> for more information on
+readiness notification. </li>
<li> <tt>-v <em>verbosity</em></tt> : be more or less
verbose. <em>verbosity</em> can be 0 (quiet), 1 (normal), or 2 or more
(verbose). </li>
diff --git a/doc/s6-ipcserverd.html b/doc/s6-ipcserverd.html
@@ -77,10 +77,9 @@ IPCREMOTEEUID will be set, but empty.
<li> <tt>-1</tt> : write a newline to stdout, and close stdout,
right before entering the client-accepting loop.
If stdout is suitably redirected, this can be used by monitoring
-programs to check when the server is accepting connections.
-The <a href="s6-notifywhenup.html">s6-notifywhenup</a>
-program can be used before the s6-ipcserver
-invocation to notify listeners when the server is ready. </li>
+programs to check when the server is accepting connections. See
+<a href="notifywhenup.html">this page</a> for more information on
+readiness notification. </li>
<li> <tt>-v <em>verbosity</em></tt> : be more or less
verbose. <em>verbosity</em> can be 0 (quiet), 1 (normal), or 2
(verbose). </li>
diff --git a/doc/s6-supervise.html b/doc/s6-supervise.html
@@ -111,7 +111,9 @@ daemon as <tt>fdmove -c 2 1 fdmove 1 3 prog...</tt> (in execline), or
<a href="s6-svc.html">s6-svc -xd</a> command had been received </li>
<li> SIGHUP: exit as soon as the service stops, as if a
<a href="s6-svc.html">s6-svc -x</a> command had been received </li>
- <li> SIGQUIT: currently like SIGTERM, but this might change in the future </li>
+ <li> SIGQUIT: close stdin, stdout and stderr and exit as soon as
+the service stops, as if a
+<a href="s6-svc.html">s6-svc -X</a> command had been received </li>
</ul>
<h2> Usage notes </h2>
diff --git a/doc/s6-svc.html b/doc/s6-svc.html
@@ -60,6 +60,13 @@ Automatically restart it when it dies. </li>
<li> <tt>-x</tt> : exit. When the service is asked to be down and
the supervised process dies, s6-supervise will exit too. This command should
normally never be used on a working system. </li>
+ <li> <tt>-X</tt> : close fds and exit. Like <tt>-x</tt>, but
+<a href="s6-supervise.html">s6-supervise</a> will immediately close its
+stdin, stdout and stderr. This is useful when s6-supervise has descriptors
+open to the service it is supervising and the service is waiting for them
+to close before exiting. Note that if this option is used, the last
+execution of the service's <tt>finish</tt> script will be run with
+stdin, stdout and stderr redirected to <tt>/dev/null</tt>. </li>
<li> <tt>-O</tt> : Once at most. Do not restart the supervised process
when it dies. If it is down when the command is received, do not even start
it. </li>
@@ -71,9 +78,10 @@ timeout is 0, which means that s6-svc will block indefinitely. </li>
<li> <tt>-D</tt> : s6-svc will not exit until the service is down. </li>
<li> <tt>-U</tt> : s6-svc will not exit until the service is up and
<a href="notifywhenup.html">ready</a> as notified by the daemon itself.
-Be careful to only use this command on services that send readiness
-notifications and are managed by <a href="s6-notifywhenup.html">s6-notifywhenup</a>,
-else the command will never be successful. </li>
+If the <a href="servicedir.html">service directory</a> does not contain
+a <tt>notification-fd</tt> file to tell
+<a href="s6-supervise.html">s6-supervise</a> to accept readiness
+notification, s6-svc will print a warning and ignore the command. </li>
</ul>
<h2> Usage examples </h2>
diff --git a/doc/upgrade.html b/doc/upgrade.html
@@ -18,6 +18,17 @@
<h1> What has changed in s6 </h1>
+<h2> in 2.1.6.0 </h2>
+
+<ul>
+ <li> <a href="s6-svc.html">s6-svc</a> now checks for the existence
+of <tt>notification-fd</tt> before accepting a <tt>U</tt> command. </li>
+ <li> New <tt>-X</tt> option to <a href="s6-svc.html">s6-svc</a>. </li>
+ <li> Different meaning of SIGQUIT for
+<a href="s6-supervise">s6-supervise</a>: now the same as
+<tt>s6-svc -X</tt>. </li>
+</ul>
+
<h2> in 2.1.5.0 </h2>
<ul>
diff --git a/package/info b/package/info
@@ -1,4 +1,4 @@
package=s6
-version=2.1.5.0
+version=2.1.6.0
category=admin
package_macro_name=S6
diff --git a/src/supervision/s6-supervise.c b/src/supervision/s6-supervise.c
@@ -27,7 +27,7 @@ enum trans_e
{
V_TIMEOUT, V_CHLD, V_TERM, V_HUP, V_QUIT,
V_a, V_b, V_q, V_h, V_k, V_t, V_i, V_1, V_2, V_f, V_F, V_p, V_c,
- V_o, V_d, V_u, V_x, V_O
+ V_o, V_d, V_u, V_x, V_O, V_X
} ;
typedef enum state_e state_t, *state_t_ref ;
@@ -85,6 +85,16 @@ static void bail (void)
cont = 0 ;
}
+static void closethem (void)
+{
+ fd_close(0) ;
+ fd_close(1) ;
+ fd_close(2) ;
+ open_readb("/dev/null") ;
+ open_write("/dev/null") ; ndelay_off(1) ;
+ open_write("/dev/null") ; ndelay_off(2) ;
+}
+
static void killa (void)
{
kill(status.pid, SIGALRM) ;
@@ -376,6 +386,12 @@ static void up_x (void)
state = LASTUP ;
}
+static void up_X (void)
+{
+ closethem() ;
+ up_x() ;
+}
+
static void up_term (void)
{
up_x() ;
@@ -409,28 +425,34 @@ static void finish_x (void)
state = LASTFINISH ;
}
+static void finish_X (void)
+{
+ closethem() ;
+ finish_x() ;
+}
+
static void lastup_z (void)
{
uplastup_z(1) ;
}
-static action_t_ref const actions[5][23] =
+static action_t_ref const actions[5][24] =
{
{ &downtimeout, &nop, &bail, &bail, &bail,
&nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop,
- &down_o, &down_d, &down_u, &bail, &down_O },
- { &uptimeout, &up_z, &up_term, &up_x, &up_term,
+ &down_o, &down_d, &down_u, &bail, &down_O, &bail },
+ { &uptimeout, &up_z, &up_term, &up_x, &up_X,
&killa, &killb, &killq, &killh, &killk, &killt, &killi, &kill1, &kill2, &nop, &nop, &killp, &killc,
- &up_o, &up_d, &up_u, &up_x, &up_o },
- { &finishtimeout, &finish_z, &finish_x, &finish_x, &finish_x,
+ &up_o, &up_d, &up_u, &up_x, &up_o, &up_X },
+ { &finishtimeout, &finish_z, &finish_x, &finish_x, &finish_X,
&nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop,
- &up_o, &down_d, &finish_u, &finish_x, &up_o },
- { &uptimeout, &lastup_z, &up_d, &nop, &up_d,
+ &up_o, &down_d, &finish_u, &finish_x, &up_o, &finish_X },
+ { &uptimeout, &lastup_z, &up_d, &nop, &closethem,
&killa, &killb, &killq, &killh, &killk, &killt, &killi, &kill1, &kill2, &nop, &nop, &killp, &killc,
- &up_o, &up_d, &nop, &nop, &up_o },
- { &finishtimeout, &bail, &nop, &nop, &nop,
+ &up_o, &up_d, &nop, &nop, &up_o, &closethem },
+ { &finishtimeout, &bail, &nop, &nop, &closethem,
&nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop,
- &nop, &nop, &nop, &nop, &nop }
+ &nop, &nop, &nop, &nop, &nop, &closethem }
} ;
@@ -511,8 +533,8 @@ static inline void handle_control (int fd)
else if (!r) break ;
else
{
- register unsigned int pos = byte_chr("abqhkti12fFpcoduxO", 18, c) ;
- if (pos < 18) (*actions[state][V_a + pos])() ;
+ register unsigned int pos = byte_chr("abqhkti12fFpcoduxOX", 19, c) ;
+ if (pos < 19) (*actions[state][V_a + pos])() ;
}
}
}
diff --git a/src/supervision/s6-svc.c b/src/supervision/s6-svc.c
@@ -1,5 +1,7 @@
/* ISC license. */
+#include <unistd.h>
+#include <errno.h>
#include <skalibs/uint.h>
#include <skalibs/bytestr.h>
#include <skalibs/sgetopt.h>
@@ -8,7 +10,7 @@
#include <s6/config.h>
#include <s6/s6-supervise.h>
-#define USAGE "s6-svc [ -D | -U ] [ -T timeout ] [ -abqhkti12pcoduxO ] servicedir"
+#define USAGE "s6-svc [ -D | -U ] [ -T timeout ] [ -abqhkti12pcoduxOX ] servicedir"
#define dieusage() strerr_dieusage(100, USAGE)
#define DATASIZE 63
@@ -24,7 +26,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
subgetopt_t l = SUBGETOPT_ZERO ;
for (;;)
{
- register int opt = subgetopt_r(argc, argv, "DUabqhkti12pcoduxOT:", &l) ;
+ register int opt = subgetopt_r(argc, argv, "DUabqhkti12pcoduxOXT:", &l) ;
if (opt == -1) break ;
switch (opt)
{
@@ -46,6 +48,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
case 'u' :
case 'x' :
case 'O' :
+ case 'X' :
{
if (datalen >= DATASIZE) strerr_dief1x(100, "too many commands") ;
data[datalen++] = opt ;
@@ -59,6 +62,21 @@ int main (int argc, char const *const *argv, char const *const *envp)
}
if (!argc) dieusage() ;
if (argc > 1) strerr_warn1x("ignoring extra arguments") ;
+
+ if (updown[1] == 'U')
+ {
+ unsigned int arglen = str_len(argv[0]) ;
+ char fn[arglen + 17] ;
+ byte_copy(fn, arglen, argv[0]) ;
+ byte_copy(fn + arglen, 17, "/notification-fd") ;
+ if (access(fn, F_OK) < 0)
+ {
+ if (errno != ENOENT) strerr_diefu2sys(111, "access ", fn) ;
+ updown[1] = 0 ;
+ strerr_warnw2x(fn, "not present - ignoring -U option") ;
+ }
+ }
+
if (updown[1])
{
char const *newargv[11] ;