diff --git a/src/widgets/terminal/Command.zig b/src/widgets/terminal/Command.zig index c61229a..e9e8dc8 100644 --- a/src/widgets/terminal/Command.zig +++ b/src/widgets/terminal/Command.zig @@ -49,19 +49,23 @@ pub fn spawn(self: *Command, allocator: std.mem.Allocator) !void { _ = err catch {}; } - var act = posix.Sigaction{ - .handler = .{ .handler = handleSigChild }, - .mask = switch (builtin.os.tag) { - .macos => 0, - .linux => posix.empty_sigset, - else => @compileError("os not supported"), - }, - .flags = 0, - }; - try posix.sigaction(posix.SIG.CHLD, &act, null); - // we are the parent self.pid = @intCast(pid); + + if (!Terminal.global_sigchild_installed) { + Terminal.global_sigchild_installed = true; + var act = posix.Sigaction{ + .handler = .{ .handler = handleSigChild }, + .mask = switch (builtin.os.tag) { + .macos => 0, + .linux => posix.empty_sigset, + else => @compileError("os not supported"), + }, + .flags = 0, + }; + try posix.sigaction(posix.SIG.CHLD, &act, null); + } + return; } diff --git a/src/widgets/terminal/Terminal.zig b/src/widgets/terminal/Terminal.zig index abf292c..7647a66 100644 --- a/src/widgets/terminal/Terminal.zig +++ b/src/widgets/terminal/Terminal.zig @@ -46,6 +46,7 @@ pub const InputEvent = union(enum) { pub var global_vt_mutex: std.Thread.Mutex = .{}; pub var global_vts: ?std.AutoHashMap(i32, *Terminal) = null; +pub var global_sigchild_installed: bool = false; allocator: std.mem.Allocator, scrollback_size: usize,