widgets(terminal): ensure only one sigchild handler installed
This commit is contained in:
parent
bf0828f9ef
commit
cea5798db9
2 changed files with 16 additions and 11 deletions
|
@ -49,6 +49,11 @@ pub fn spawn(self: *Command, allocator: std.mem.Allocator) !void {
|
|||
_ = err catch {};
|
||||
}
|
||||
|
||||
// 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) {
|
||||
|
@ -59,9 +64,8 @@ pub fn spawn(self: *Command, allocator: std.mem.Allocator) !void {
|
|||
.flags = 0,
|
||||
};
|
||||
try posix.sigaction(posix.SIG.CHLD, &act, null);
|
||||
}
|
||||
|
||||
// we are the parent
|
||||
self.pid = @intCast(pid);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue