From d567a976b46f71ed815f07ed68fd12a8b384aad9 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 16 Nov 2022 20:54:17 -0800 Subject: [PATCH] waitpid should specify WNOHANG If the child process our terminal is executing behaves poorly and doesn't waitpid all of its own children, then we can hang the full terminal. This is not ideal, so specify WNOHANG. --- src/Command.zig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Command.zig b/src/Command.zig index 121b91a45..1e63d9161 100644 --- a/src/Command.zig +++ b/src/Command.zig @@ -186,7 +186,10 @@ fn setupFd(src: File.Handle, target: i32) !void { /// Wait for the command to exit and return information about how it exited. pub fn wait(self: Command) !Exit { - const res = std.os.waitpid(self.pid.?, 0); + // We specify NOHANG because its not our fault if the process we launch + // for the tty doesn't properly waitpid its children. We don't want + // to hang the terminal over it. + const res = std.os.waitpid(self.pid.?, std.c.W.NOHANG); return Exit.init(res.status); }