pub fn suppressing_diagnostic_signals(write: impl FnOnce() -> i32)Expand description
Run one diagnostic write (write returns its errno, 0 for none) so that no
signal it generates escapes.
Reverie’s container setup restores SIGPIPE’s default disposition and
clears the signal mask in the process that runs the tracer. Under
--no-namespace that was an ordinary process, and round 2 of the review of
https://github.com/rrnewton/hermit/pull/3686 found a SIGPIPE from its
crossing line killing it before _exit(123), reported as an internal
failure (125); the cap is refused there now. In hermit’s PID namespace the
tracer runs in the container init, PID 1 of the namespace, and the kernel
discards a signal at its default disposition that the init raises in
itself, so there the guard is a defence rather than the fix: it keeps any
process in which this writer runs with SIGPIPE at its default from dying
before the exit.
As in proc_mount’s warning writer, SIGPIPE and SIGXFSZ (a file-size
limit) are blocked for the attempt, and a signal is consumed only when this
write failed with the matching error and the signal was not already pending
before it. SIGTTOU is blocked too: a terminal with TOSTOP treats a
blocked SIGTTOU as ignored and accepts the write, instead of stopping a
background process. The original mask is restored afterwards.