mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
Merge pull request #2277 from ghostty-org/kill
termio: killpg expected to fail on darwin, still go into waitpid loop
This commit is contained in:
@ -1257,9 +1257,19 @@ const Subprocess = struct {
|
|||||||
// descendents are well and truly dead. We will not rest
|
// descendents are well and truly dead. We will not rest
|
||||||
// until the entire family tree is obliterated.
|
// until the entire family tree is obliterated.
|
||||||
while (true) {
|
while (true) {
|
||||||
if (c.killpg(pgid, c.SIGHUP) < 0) {
|
switch (posix.errno(c.killpg(pgid, c.SIGHUP))) {
|
||||||
log.warn("error killing process group pgid={}", .{pgid});
|
.SUCCESS => log.debug("process group killed pgid={}", .{pgid}),
|
||||||
return error.KillFailed;
|
else => |err| killpg: {
|
||||||
|
if ((comptime builtin.target.isDarwin()) and
|
||||||
|
err == .PERM)
|
||||||
|
{
|
||||||
|
log.debug("killpg failed with EPERM, expected on Darwin and ignoring", .{});
|
||||||
|
break :killpg;
|
||||||
|
}
|
||||||
|
|
||||||
|
log.warn("error killing process group pgid={} err={}", .{ pgid, err });
|
||||||
|
return error.KillFailed;
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// See Command.zig wait for why we specify WNOHANG.
|
// See Command.zig wait for why we specify WNOHANG.
|
||||||
@ -1267,6 +1277,7 @@ const Subprocess = struct {
|
|||||||
// are still alive without blocking so that we can
|
// are still alive without blocking so that we can
|
||||||
// kill them again.
|
// kill them again.
|
||||||
const res = posix.waitpid(pid, std.c.W.NOHANG);
|
const res = posix.waitpid(pid, std.c.W.NOHANG);
|
||||||
|
log.debug("waitpid result={}", .{res.pid});
|
||||||
if (res.pid != 0) break;
|
if (res.pid != 0) break;
|
||||||
std.time.sleep(10 * std.time.ns_per_ms);
|
std.time.sleep(10 * std.time.ns_per_ms);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user