Re: s6-log not responding to signals

From: Laurent Bercot <ska-skaware_at_skarnet.org>
Date: Fri, 26 May 2023 08:52:49 +0000

>How are you thinking changes to termination behaviour will interact with the existing -p option?

  There would be no specific interaction.
  -p only makes s6-log ignore SIGTERM. The signal is received, but does
nothing.
  The new timeout option would make it wait on receipt of an exit signal,
be it SIGTERM or SIGHUP. So, with -p, it would only trigger the new
behaviour on SIGHUP, and keep doing nothing on SIGTERM.


>As suggested by the documentation, when s6-log is waiting for a newline to arrive,
>its behaviour could be influenced by a) EOF on stdin, b) termination signal.
>
>Are you thinking of adding the timeout only if there is a termination signal,
>but EOF has not yet been detected?

  There are two exit conditions for s6-log:
  1. it reads EOF on stdin;
  2. it receives a SIGTERM (unless -p), or a SIGHUP.

  On EOF, s6-log exits *immediately*. If it has a partial line in its
buffer, it will process and log it as a full line before exiting. It
does not wait because there is no reason to: the producer closed the
data stream, so s6-log is never getting any more data to finish the
line.

  On a termination signal, the producer isn't necessarily done sending
logs; the signal comes from a third party (the administrator). s6-log's
goal is to exit asap but without losing any data, and on a line
boundary.
If there's nothing in its buffer, it exits immediately, but if there's
a partial line, it will wait for the producer to send it the rest of
the line, process this line, and then exit without reading anything
more.
  (If the producer has more to send, it can do so if the pipe to s6-log
is being fd-held; the next s6-log incarnation then resumes where the
old one has stopped. If the pipe isn't being fd-held, then the producer
gets a broken pipe error, but knows exactly what it has successfully
sent and what it has not: no data has been lost in a buffer.)

  My suggestion is to add a timeout in the only case s6-log doesn't
exit immediately: when it gets a termination signal and there is a
partial line in the buffer. The wait is meant to give some leeway for
the producer to send the rest of the line before s6-log exits, but if
no such rest of the line is coming, it would be better for s6-log not
to wait forever.

--
  Laurent
Received on Fri May 26 2023 - 10:52:49 CEST

This archive was generated by hypermail 2.4.0 : Fri May 26 2023 - 10:53:17 CEST