From 164da9fc0a7ab3c7ed39ea0a2dd6bbff3c36cdaf Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 29 Sep 2026 13:39:12 -0300 Subject: Every child starts with its signals at their defaults and none blocked Shells, command panes, language servers, the link opener and the v9fs mount inherited the editor's signal mask (the tty's blocked SIGWINCH) and anything it ignored (a SIGHUP nohup ignored), since only handlers reset at exec. Each fork now resets every disposition and clears the mask before its exec (resetChildSignals); std's spawn for selection pipes runs with the mask cleared across it. Co-Authored-By: Claude Opus 5.5 --- src/selection_pipe.zig | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/selection_pipe.zig') diff --git a/src/selection_pipe.zig b/src/selection_pipe.zig index e1a42962..44cc1709 100644 --- a/src/selection_pipe.zig +++ b/src/selection_pipe.zig @@ -202,6 +202,14 @@ pub fn runOne( if (std.mem.indexOfScalar(u8, command, 0) != null or std.mem.indexOfScalar(u8, cwd, 0) != null) return fail.k(.spawn); + // std's spawn runs no code in the child: this thread's mask, which the + // child inherits, is cleared across the fork (only the tty's SIGWINCH is + // ever blocked, and its default is to be ignored). A handler resets at + // exec by itself, and nothing here is ignored. + const none = std.posix.sigemptyset(); + var kept: std.posix.sigset_t = undefined; + std.posix.sigprocmask(std.posix.SIG.SETMASK, &none, &kept); + defer std.posix.sigprocmask(std.posix.SIG.SETMASK, &kept, null); var child = std.process.spawn(io, .{ .argv = &.{ "/bin/sh", "-c", command }, .cwd = if (cwd.len == 0) .inherit else .{ .path = cwd }, -- cgit v1.3