| ... | @@ -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 | } |
| 3123 | | 3123 | |
| 3124 | pub const WaitpidRet = struct { | 3124 | pub const WaitPidResult = struct { |
| 3125 | pid: pid_t, status: u32 | 3125 | pid: pid_t, |
| | 3126 | status: u32, |
| 3126 | }; | 3127 | }; |
| 3127 | | 3128 | |
| 3128 | pub fn waitpid(pid: pid_t, flags: u32) WaitpidRet { | 3129 | pub 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 invalid | 3141 | 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 | } |
| 5441 | | 5444 | |
| 5442 | pub const SetrlimitError = error{ | 5445 | pub const SetrlimitError = error{PermissionDenied} || UnexpectedError; |
| 5443 | PermissionDenied, | | |
| 5444 | } || UnexpectedError; | | |
| 5445 | | 5446 | |
| 5446 | pub fn setrlimit(resource: rlimit_resource, limits: rlimit) SetrlimitError!void { | 5447 | pub fn setrlimit(resource: rlimit_resource, limits: rlimit) SetrlimitError!void { |
| 5447 | // TODO implement for systems other than linux and enable test | 5448 | // TODO implement for systems other than linux and enable test |