diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-23 09:02:22 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-23 09:57:18 -0300 |
| commit | 0477ea526bb22604ec51c7d58cf566952fe2fdf0 (patch) | |
| tree | 6f3f6d6fca4d9e7a9b664ce768eaff05edd598dc | |
| parent | 62479337e68da42e013e449ef680826a323354f1 (diff) | |
| download | pardes-0477ea526bb22604ec51c7d58cf566952fe2fdf0.tar.gz pardes-0477ea526bb22604ec51c7d58cf566952fe2fdf0.zip | |
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 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
| -rw-r--r-- | runtime/daemon.zig | 9 | ||||
| -rw-r--r-- | test/daemon.py | 41 |
2 files changed, 48 insertions, 2 deletions
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); diff --git a/test/daemon.py b/test/daemon.py index 7f1adfdb..34c4c7a6 100644 --- a/test/daemon.py +++ b/test/daemon.py @@ -2870,6 +2870,46 @@ def cpu_ticks(pid): return int(stat[11]) + int(stat[12]) +def killed_session(binary): + """A terminal's session killed outright (KILL, as the OOM killer does): + the job its terminal waits on ends with it, and says nothing of its own + (no trace): the own path's stub dead of the same signal, as a job is + (daemon.zig `stubWait`, which aborted re-raising a KILL); a pair's + client let go of its session, 1.""" + scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' + scratch.mkdir(parents=True, exist_ok=True) + root = Path(tempfile.mkdtemp(prefix='rk-', dir=scratch)) + env = base_env() + env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), + TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1') + (root / 'config' / 'pardes').mkdir(parents=True) + (root / 'config' / 'pardes' / 'init').write_text('Shell bash\nMessageLinger 0\n') + notes = root / 'notes.txt' + notes.write_text(''.join(f'line {i} of the notes\n' for i in range(30))) + t = Term(30, 100) + try: + c = t.spawn([binary, '--9p=k', str(notes)], env) + sock = root / 'pardes-9p-k.sock' + wait_for('the socket', sock.exists) + with Client(sock) as nine: + session = int(dict(line.split(maxsplit=1) for line in nine.read('/status').decode().splitlines())['pid']) + wait_for('drawn', lambda: b'line 3 of the notes' in t.text(), timeout=30) + os.kill(session, signal.SIGKILL) + code = c.wait(timeout=30) + said = t.last() + assert b'panic' not in said and b'unreachable' not in said, said[-1500:] + assert code == (1 if WITH_PAIR else -signal.SIGKILL), (code, said[-600:]) + print(f'killed session: its terminal\'s job ended {code} with it, no trace') + finally: + for p in processes(root): + try: + os.kill(p, signal.SIGKILL) + except OSError: + pass + t.close() + shutil.rmtree(root, ignore_errors=True) + + def kitty_image(binary, secs=5): """A plain attach watching a terminal in which a program shows a kitty image (the corpus's scene 10's: 8x8 RGB, 10x4 cells): it @@ -4132,3 +4172,4 @@ if __name__ == '__main__': gui_pair(args[0]) else: main(sys.argv[1], int(sys.argv[2]) if len(sys.argv) > 2 else 50) + killed_session(sys.argv[1]) |
