From 0477ea526bb22604ec51c7d58cf566952fe2fdf0 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 23 Nov 2026 09:02:22 -0300 Subject: daemon: the stub dies of its session's KILL as of any other signal, not of an abort: a terminal's session killed outright (kill -9, the OOM killer) left its stub, the job the shell waits on, dead of SIGABRT (-6, $? 134) with a Zig trace printed on the user's terminal (pardes-pair-13's z6/sees.py on pardes-m63-base's Debug build: `std/posix.zig:954 in sigaction: .INVAL => unreachable` from runtime/daemon.zig:680 `stubWait`), because stubWait re-raises the signal its session died of after setting that signal's action to the default, and KILL's action cannot be set (EINVAL, which std's posix.sigaction takes as unreachable); a user of the installed build can hit it (the own path is its default); now the action is set for any signal but KILL (its default already) and the stub dies of the KILL (-9, $? 137); the row `killed_session` (test/daemon.py, plain mode, both ways by its one switch): the session killed with KILL, the job ends with no trace on its terminal, -9 on the own path and 1 for a pair's client (let go: "'x' let this client go"); sees.py after: the own path -9 and no trace; core-test 931/1095 (164 skipped), shell-test 1137/1140 (3 skipped), process-test 0 of 146 both ways (with the next change, loads 2.1-11) Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- runtime/daemon.zig | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'runtime/daemon.zig') diff --git a/runtime/daemon.zig b/runtime/daemon.zig index a964eb0b..97941a12 100644 --- a/runtime/daemon.zig +++ b/runtime/daemon.zig @@ -676,8 +676,13 @@ fn stubWait(session: libc.pid_t, pipe: c_int) noreturn { if (libc.W.IFEXITED(s)) libc._exit(@intCast(libc.W.EXITSTATUS(s))); if (libc.W.IFSIGNALED(s)) { const sig = libc.W.TERMSIG(s); - const default: posix.Sigaction = .{ .handler = .{ .handler = posix.SIG.DFL }, .mask = posix.sigemptyset(), .flags = 0 }; - posix.sigaction(sig, &default, null); + // A KILL's action is its default already and cannot be set + // (EINVAL: posix.sigaction's unreachable, the stub aborting with a + // trace on the terminal); any other is put back to it first. + if (sig != .KILL) { + const default: posix.Sigaction = .{ .handler = .{ .handler = posix.SIG.DFL }, .mask = posix.sigemptyset(), .flags = 0 }; + posix.sigaction(sig, &default, null); + } _ = libc.raise(sig); } libc._exit(1); -- cgit v1.3