commit 3457a5ce01d7df3bc4cdc6259736ca210b4d4765
parent c02e7ac089342801f7f0d3e6f6ebb3eee56959d1
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date: Thu, 25 May 2023 15:59:58 +0000
Add s6-svc -s; prepare for 2.11.4.0
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat:
7 files changed, 55 insertions(+), 7 deletions(-)
diff --git a/INSTALL b/INSTALL
@@ -6,7 +6,7 @@ Build Instructions
- A POSIX-compliant C development environment
- GNU make version 3.81 or later
- - skalibs version 2.13.1.1 or later: https://skarnet.org/software/skalibs/
+ - skalibs version 2.13.2.0 or later: https://skarnet.org/software/skalibs/
- execline version 2.9.3.0 or later: https://skarnet.org/software/execline/
(You can disable this requirement at configure time, but will
lose some functionality.)
diff --git a/NEWS b/NEWS
@@ -1,5 +1,11 @@
Changelog for s6.
+In 2.11.4.0
+-----------
+
+ - New option to s6-svc: -s, to specify a signal by name (or number).
+
+
In 2.11.3.2
-----------
diff --git a/doc/index.html b/doc/index.html
@@ -83,7 +83,7 @@ with s6</a> </li>
<li> A POSIX-compliant system with a standard C development environment </li>
<li> GNU make, version 3.81 or later </li>
<li> <a href="//skarnet.org/software/skalibs/">skalibs</a> version
-2.13.1.1 or later. It's a build-time requirement. It's also a run-time
+2.13.2.0 or later. It's a build-time requirement. It's also a run-time
requirement if you link against the shared version of the skalibs
library. </li>
<li> (Optional, but really recommended for full functionality):
@@ -115,7 +115,7 @@ want nsswitch-like functionality:
<h3> Download </h3>
<ul>
- <li> The current released version of s6 is <a href="s6-2.11.3.2.tar.gz">2.11.3.2</a>. </li>
+ <li> The current released version of s6 is <a href="s6-2.11.4.0.tar.gz">2.11.4.0</a>. </li>
<li> Alternatively, you can checkout a copy of the
<a href="//git.skarnet.org/cgi-bin/cgit.cgi/s6/">s6
git repository</a>:
diff --git a/doc/s6-svc.html b/doc/s6-svc.html
@@ -28,7 +28,7 @@ knowing their PIDs, and without using horrible hacks such as .pid files.
<h2> Interface </h2>
<pre>
- s6-svc [ -wu | -wU | -wd | -wD | -wr | -wR ] [ -T <em>timeout</em> ] [ -abqhkti12pcyroduDUxO ] <em>servicedir</em>
+ s6-svc [ -wu | -wU | -wd | -wD | -wr | -wR ] [ -T <em>timeout</em> ] [ -s <em>signal</em> | -abqhkti12pcy ] [ -roduDUxO ] <em>servicedir</em>
</pre>
<p>
@@ -53,6 +53,13 @@ a command, or 100 if no s6-supervise process is running on <em>servicedir</em>.
<li> <tt>-p</tt> : send a SIGSTOP to the supervised process </li>
<li> <tt>-c</tt> : send a SIGCONT to the supervised process </li>
<li> <tt>-y</tt> : send a SIGWINCH to the supervised process </li>
+ <li> <tt>-s <em>signal</em></tt> : send <em>signal</em> to the
+supervised process. <em>signal</em> can be given as its name (case-
+insensitive) or its number, but only the signals listed above are
+accepted - you cannot, for instance, manually send a SIGSEGV to the
+supervised process. </li>
+</ul> <br />
+<ul>
<li> <tt>-o</tt> : once. Equivalent to "-uO". </li>
<li> <tt>-d</tt> : down. If the supervised process is up, send it
a SIGTERM (by default) then a SIGCONT (to make sure even stopped processes
diff --git a/doc/upgrade.html b/doc/upgrade.html
@@ -18,6 +18,13 @@
<h1> What has changed in s6 </h1>
+<h2> in 2.11.4.0 </h2>
+
+<ul>
+ <li> <a href="//skarnet.org/software/skalibs/">skalibs</a>
+dependency bumped to 2.13.2.0. </li>
+</ul>
+
<h2> in 2.11.3.2 </h2>
<ul>
diff --git a/package/info b/package/info
@@ -1,4 +1,4 @@
package=s6
-version=2.11.3.2
+version=2.11.4.0
category=admin
package_macro_name=S6
diff --git a/src/supervision/s6-svc.c b/src/supervision/s6-svc.c
@@ -1,25 +1,46 @@
/* ISC license. */
+#include <skalibs/nonposix.h>
+
#include <string.h>
#include <unistd.h>
#include <errno.h>
+#include <signal.h>
#include <skalibs/types.h>
#include <skalibs/sgetopt.h>
#include <skalibs/strerr.h>
+#include <skalibs/nsig.h>
+#include <skalibs/sig.h>
#include <skalibs/djbunix.h>
#include <skalibs/exec.h>
#include <s6/config.h>
#include <s6/supervise.h>
-#define USAGE "s6-svc [ -wu | -wU | -wd | -wD | -wr | -wR ] [ -T timeout ] [ -abqhkti12pcyroduDUxOQ ] servicedir"
+#define USAGE "s6-svc [ -wu | -wU | -wd | -wD | -wr | -wR ] [ -T timeout ] [ -s signal | -abqhkti12pcy ] [ -roduDUxOQ ] servicedir"
#define dieusage() strerr_dieusage(100, USAGE)
#define DATASIZE 63
int main (int argc, char const *const *argv)
{
+ static char const cmdsig[NSIG] =
+ {
+ 0,
+ [SIGALRM] = 'a',
+ [SIGABRT] = 'b',
+ [SIGQUIT] = 'q',
+ [SIGHUP] = 'h',
+ [SIGKILL] = 'k',
+ [SIGTERM] = 't',
+ [SIGINT] = 'i',
+ [SIGUSR1] = '1',
+ [SIGUSR2] = '2',
+ [SIGSTOP] = 'p',
+ [SIGCONT] = 'c',
+ [SIGWINCH] = 'y'
+ } ;
size_t len ;
unsigned int datalen = 1 ;
unsigned int timeout = 0 ;
@@ -30,10 +51,17 @@ int main (int argc, char const *const *argv)
subgetopt l = SUBGETOPT_ZERO ;
for (;;)
{
- int opt = subgetopt_r(argc, argv, "abqhkti12pcyroduDUxOQT:w:", &l) ;
+ int opt = subgetopt_r(argc, argv, "s:abqhkti12pcyroduDUxOQT:w:", &l) ;
if (opt == -1) break ;
switch (opt)
{
+ case 's' :
+ {
+ int sig ;
+ if (!sig0_scan(l.arg, &sig)) strerr_dief2x(100, "invalid signal: ", l.arg) ;
+ if (!cmdsig[sig]) strerr_dief2x(100, l.arg, " is not in the list of user-available signals") ;
+ opt = cmdsig[sig] ;
+ }
case 'a' :
case 'b' :
case 'q' :