Commit 5c16022c81

Andrew Kelley <andrew@ziglang.org>
2020-10-17 03:14:39
rename WaitpidRet to WaitPidResult
1 parent 3921cb0
Changed files (2)
lib/std/child_process.zig
@@ -269,9 +269,9 @@ pub const ChildProcess = struct {
     }
 
     fn waitUnwrapped(self: *ChildProcess) void {
-        const ret = os.waitpid(self.pid, 0);
+        const status = os.waitpid(self.pid, 0).status;
         self.cleanupStreams();
-        self.handleWaitResult(ret.status);
+        self.handleWaitResult(status);
     }
 
     fn handleWaitResult(self: *ChildProcess, status: u32) void {
lib/std/os.zig
@@ -3121,21 +3121,24 @@ pub fn getsockoptError(sockfd: fd_t) ConnectError!void {
     }
 }
 
-pub const WaitpidRet = struct {
-    pid: pid_t, status: u32
+pub const WaitPidResult = struct {
+    pid: pid_t,
+    status: u32,
 };
 
-pub fn waitpid(pid: pid_t, flags: u32) WaitpidRet {
-    // TODO allow implicit pointer cast from *u32 to *c_uint ?
+pub fn waitpid(pid: pid_t, flags: u32) WaitPidResult {
     const Status = if (builtin.link_libc) c_uint else u32;
     var status: Status = undefined;
     while (true) {
         const rc = system.waitpid(pid, &status, flags);
         switch (errno(rc)) {
-            0 => return WaitpidRet{ .pid = @intCast(pid_t, rc), .status = @bitCast(u32, status) },
+            0 => return .{
+                .pid = @intCast(pid_t, rc),
+                .status = @bitCast(u32, status),
+            },
             EINTR => continue,
             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,
         }
     }
@@ -5439,9 +5442,7 @@ pub fn getrlimit(resource: rlimit_resource) GetrlimitError!rlimit {
     }
 }
 
-pub const SetrlimitError = error{
-    PermissionDenied,
-} || UnexpectedError;
+pub const SetrlimitError = error{PermissionDenied} || UnexpectedError;
 
 pub fn setrlimit(resource: rlimit_resource, limits: rlimit) SetrlimitError!void {
     // TODO implement for systems other than linux and enable test