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 {
269269 }
270270
271271 fn waitUnwrapped(self: *ChildProcess) void {
272 const ret = os.waitpid(self.pid, 0);
272 const status = os.waitpid(self.pid, 0).status;
273273 self.cleanupStreams();
274 self.handleWaitResult(ret.status);
274 self.handleWaitResult(status);
275275 }
276276
277277 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 {
31213121 }
31223122}
31233123
3124pub const WaitpidRet = struct {
3125 pid: pid_t, status: u32
3124pub const WaitPidResult = struct {
3125 pid: pid_t,
3126 status: u32,
31263127};
31273128
3128pub fn waitpid(pid: pid_t, flags: u32) WaitpidRet {
3129 // TODO allow implicit pointer cast from *u32 to *c_uint ?
3129pub fn waitpid(pid: pid_t, flags: u32) WaitPidResult {
31303130 const Status = if (builtin.link_libc) c_uint else u32;
31313131 var status: Status = undefined;
31323132 while (true) {
31333133 const rc = system.waitpid(pid, &status, flags);
31343134 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 },
31363139 EINTR => continue,
31373140 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 invalid
3141 EINVAL => unreachable, // Invalid flags.
31393142 else => unreachable,
31403143 }
31413144 }
......@@ -5439,9 +5442,7 @@ pub fn getrlimit(resource: rlimit_resource) GetrlimitError!rlimit {
54395442 }
54405443}
54415444
5442pub const SetrlimitError = error{
5443 PermissionDenied,
5444} || UnexpectedError;
5445pub const SetrlimitError = error{PermissionDenied} || UnexpectedError;
54455446
54465447pub fn setrlimit(resource: rlimit_resource, limits: rlimit) SetrlimitError!void {
54475448 // TODO implement for systems other than linux and enable test