feature. See also
. The project being documented here (as the example) is the Zig library itself.
Threaded.childKillPosix
fn childKillPosix(child: *process.Child) !void
File
Code
fn childKillPosix(child: *process.Child) !void {
const pid = child.id.?;
while (true) switch (posix.errno(posix.system.kill(pid, .TERM))) {
.SUCCESS => break,
.INTR => continue,
.PERM => return error.PermissionDenied,
.INVAL => |err| return errnoBug(err),
.SRCH => |err| return errnoBug(err),
else => |err| return posix.unexpectedErrno(err),
};
if (have_wait4) {
var status: if (builtin.link_libc) c_int else i32 = undefined;
while (true) switch (posix.errno(posix.system.wait4(pid, &status, 0, null))) {
.SUCCESS => return,
.INTR => continue,
.CHILD => |err| return errnoBug(err),
else => |err| return posix.unexpectedErrno(err),
};
}
if (have_waitid) {
const linux = std.os.linux;
var info: linux.siginfo_t = undefined;
while (true) switch (linux.errno(linux.waitid(.PID, pid, &info, linux.W.EXITED, null))) {
.SUCCESS => return,
.INTR => continue,
.CHILD => |err| return errnoBug(err),
else => |err| return posix.unexpectedErrno(err),
};
}
var status: if (builtin.link_libc) c_int else i32 = undefined;
while (true) switch (posix.errno(posix.system.waitpid(pid, &status, 0))) {
.SUCCESS => return,
.INTR => continue,
.CHILD => |err| return errnoBug(err),
else => |err| return posix.unexpectedErrno(err),
};
}