commit 8bbfc319248c0cbeb57edc45f26d1c972d32f505
parent 76c5586ea0b3b98ae42f2000c94c04297391f1af
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date: Mon, 23 Dec 2019 11:48:48 +0000
Add ?processor support to s6-log
Diffstat:
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/doc/s6-log.html b/doc/s6-log.html
@@ -237,6 +237,11 @@ an unpadded, unlimited status file. By default, <em>statussize</em> is 1001. </l
<tt>execlineb</tt> must be found in s6-log's PATH.
If <em>processor</em> is empty, no processor will be set for the next logdirs.
By default, no processor is set. </li>
+ <li> <strong>?<em>processor</em></strong>: registers
+<tt>/bin/sh -c <em>processor</em></tt> as a processor for the next logdirs.
+It is just like the <tt>!</tt> directive, except that the processor string
+is interpreted by <tt>/bin/sh</tt>, not <tt>execlineb</tt>. It is useful
+for people who have built s6 without execline support. </li>
<li> <strong>t</strong>: the logged line will be prepended with a
<a href="//skarnet.org/software/skalibs/libstddjb/tai.html">TAI64N
timestamp</a> (and a space) before being processed by the next action
diff --git a/src/daemontools-extras/s6-log.c b/src/daemontools-extras/s6-log.c
@@ -304,7 +304,7 @@ static int finish (logdir_t *ldp, char const *name, char suffix)
static inline void exec_processor (logdir_t *ldp)
{
- char const *cargv[4] = { EXECLINE_EXTBINPREFIX "execlineb", "-Pc", ldp->processor, 0 } ;
+ char const *cargv[4] = { ldp->flags & 4 ? "/bin/sh" : EXECLINE_EXTBINPREFIX "execlineb", ldp->flags & 4 ? "-c" : "-Pc", ldp->processor, 0 } ;
int fd ;
PROG = "s6-log (processor child)" ;
if (chdir(ldp->dir) < 0) strerr_diefu2sys(111, "chdir to ", ldp->dir) ;
@@ -714,6 +714,7 @@ static inline void script_firstpass (char const *const *argv, unsigned int *sell
case 'E' :
case '^' :
case '!' :
+ case '?' :
break ;
case 't' :
if ((*argv)[1]) goto fail ;
@@ -839,6 +840,11 @@ static inline void script_secondpass (char const *const *argv, scriptelem_t *scr
break ;
case '!' :
processor = (*argv)[1] ? *argv + 1 : 0 ;
+ flags &= ~4 ;
+ break ;
+ case '?' :
+ processor = (*argv)[1] ? *argv + 1 : 0 ;
+ flags |= 4 ;
break ;
case 't' :
flags |= 1 ;