termio/exec: use Command.wait rather than posix.waitpid

This commit is contained in:
Will Pragnell
2025-01-09 21:56:21 -08:00
parent 5a3a3fbd45
commit c3e1c4e2f1

View File

@ -1297,13 +1297,10 @@ const Subprocess = struct {
}, },
} }
// See Command.zig wait for why we specify WNOHANG. const ret = command.wait(false);
// The gist is that it lets us detect when children log.debug("wait result={}", .{ret});
// are still alive without blocking so that we can // 0 means the process is still running
// kill them again. if (ret != 0) break;
const res = posix.waitpid(pid, std.c.W.NOHANG);
log.debug("waitpid result={}", .{res.pid});
if (res.pid != 0) break;
std.time.sleep(10 * std.time.ns_per_ms); std.time.sleep(10 * std.time.ns_per_ms);
} }
}, },