authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-10-16 18:14:39-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-10-16 18:14:39-07:00
log5c16022c81effc2d684aaf21217dce0f7708946a
treef8287a9f1e07269c5ebd2d3e0a86483c23270e25
parent3921cb0d8d46c59411b6c8f35f5d271c26fba14f

rename WaitpidRet to WaitPidResult


2 files changed, 12 insertions(+), 11 deletions(-)

lib/std/child_process.zig+2-2
...@@ -269,9 +269,9 @@ pub const ChildProcess = struct {...@@ -269,9 +269,9 @@ pub const ChildProcess = struct {
269 }269 }
270270
271 fn waitUnwrapped(self: *ChildProcess) void {271 fn waitUnwrapped(self: *ChildProcess) void {
272 const ret = os.waitpid(self.pid, 0);272 const status = os.waitpid(self.pid, 0).status;
273 self.cleanupStreams();273 self.cleanupStreams();
274 self.handleWaitResult(ret.status);274 self.handleWaitResult(status);
275 }275 }
276276
277 fn handleWaitResult(self: *ChildProcess, status: u32) void {277 fn handleWaitResult(self: *ChildProcess, status: u32) void {
lib/std/os.zig+10-9
...@@ -3121,21 +3121,24 @@ pub fn getsockoptError(sockfd: fd_t) ConnectError!void {...@@ -3121,21 +3121,24 @@ pub fn getsockoptError(sockfd: fd_t) ConnectError!void {
3121 }3121 }
3122}3122}
31233123
3124pub const WaitpidRet = struct {3124pub const WaitPidResult = struct {
3125 pid: pid_t, status: u323125 pid: pid_t,
3126 status: u32,
3126};3127};
31273128
3128pub fn waitpid(pid: pid_t, flags: u32) WaitpidRet {3129pub fn waitpid(pid: pid_t, flags: u32) WaitPidResult {
3129 // TODO allow implicit pointer cast from *u32 to *c_uint ?
3130 const Status = if (builtin.link_libc) c_uint else u32;3130 const Status = if (builtin.link_libc) c_uint else u32;
3131 var status: Status = undefined;3131 var status: Status = undefined;
3132 while (true) {3132 while (true) {
3133 const rc = system.waitpid(pid, &status, flags);3133 const rc = system.waitpid(pid, &status, flags);
3134 switch (errno(rc)) {3134 switch (errno(rc)) {
3135 0 => return WaitpidRet{ .pid = @intCast(pid_t, rc), .status = @bitCast(u32, status) },3135 0 => return .{
3136 .pid = @intCast(pid_t, rc),
3137 .status = @bitCast(u32, status),
3138 },
3136 EINTR => continue,3139 EINTR => continue,
3137 ECHILD => unreachable, // The process specified does not exist. It would be a race condition to handle this error.3140 ECHILD => unreachable, // The process specified does not exist. It would be a race condition to handle this error.
3138 EINVAL => unreachable, // The options argument was invalid3141 EINVAL => unreachable, // Invalid flags.
3139 else => unreachable,3142 else => unreachable,
3140 }3143 }
3141 }3144 }
...@@ -5439,9 +5442,7 @@ pub fn getrlimit(resource: rlimit_resource) GetrlimitError!rlimit {...@@ -5439,9 +5442,7 @@ pub fn getrlimit(resource: rlimit_resource) GetrlimitError!rlimit {
5439 }5442 }
5440}5443}
54415444
5442pub const SetrlimitError = error{5445pub const SetrlimitError = error{PermissionDenied} || UnexpectedError;
5443 PermissionDenied,
5444} || UnexpectedError;
54455446
5446pub fn setrlimit(resource: rlimit_resource, limits: rlimit) SetrlimitError!void {5447pub fn setrlimit(resource: rlimit_resource, limits: rlimit) SetrlimitError!void {
5447 // TODO implement for systems other than linux and enable test5448 // TODO implement for systems other than linux and enable test