commit
2aff27d922
@ -269,7 +269,7 @@ pub const ChildProcess = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn waitUnwrapped(self: *ChildProcess) void {
|
fn waitUnwrapped(self: *ChildProcess) void {
|
||||||
const status = os.waitpid(self.pid, 0);
|
const status = os.waitpid(self.pid, 0).status;
|
||||||
self.cleanupStreams();
|
self.cleanupStreams();
|
||||||
self.handleWaitResult(status);
|
self.handleWaitResult(status);
|
||||||
}
|
}
|
||||||
|
@ -3121,16 +3121,24 @@ pub fn getsockoptError(sockfd: fd_t) ConnectError!void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn waitpid(pid: i32, flags: u32) u32 {
|
pub const WaitPidResult = struct {
|
||||||
// TODO allow implicit pointer cast from *u32 to *c_uint ?
|
pid: pid_t,
|
||||||
|
status: u32,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub fn waitpid(pid: pid_t, flags: u32) WaitPidResult {
|
||||||
const Status = if (builtin.link_libc) c_uint else u32;
|
const Status = if (builtin.link_libc) c_uint else u32;
|
||||||
var status: Status = undefined;
|
var status: Status = undefined;
|
||||||
while (true) {
|
while (true) {
|
||||||
switch (errno(system.waitpid(pid, &status, flags))) {
|
const rc = system.waitpid(pid, &status, flags);
|
||||||
0 => return @bitCast(u32, status),
|
switch (errno(rc)) {
|
||||||
|
0 => return .{
|
||||||
|
.pid = @intCast(pid_t, rc),
|
||||||
|
.status = @bitCast(u32, status),
|
||||||
|
},
|
||||||
EINTR => continue,
|
EINTR => continue,
|
||||||
ECHILD => unreachable, // The process specified does not exist. It would be a race condition to handle this error.
|
ECHILD => unreachable, // The process specified does not exist. It would be a race condition to handle this error.
|
||||||
EINVAL => unreachable, // The options argument was invalid
|
EINVAL => unreachable, // Invalid flags.
|
||||||
else => unreachable,
|
else => unreachable,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5434,9 +5442,7 @@ pub fn getrlimit(resource: rlimit_resource) GetrlimitError!rlimit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const SetrlimitError = error{
|
pub const SetrlimitError = error{PermissionDenied} || UnexpectedError;
|
||||||
PermissionDenied,
|
|
||||||
} || UnexpectedError;
|
|
||||||
|
|
||||||
pub fn setrlimit(resource: rlimit_resource, limits: rlimit) SetrlimitError!void {
|
pub fn setrlimit(resource: rlimit_resource, limits: rlimit) SetrlimitError!void {
|
||||||
// TODO implement for systems other than linux and enable test
|
// TODO implement for systems other than linux and enable test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user