| ... | @@ -2759,6 +2759,10 @@ pub const libc = struct { | ... | @@ -2759,6 +2759,10 @@ pub const libc = struct { |
| 2759 | /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/uselocale.html | 2759 | /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/uselocale.html |
| 2760 | pub extern fn uselocale(newloc: locale_t) locale_t; | 2760 | pub extern fn uselocale(newloc: locale_t) locale_t; |
| 2761 | | 2761 | |
| | 2762 | /// pid_t waitpid(pid_t pid, int *stat_loc, int options); |
| | 2763 | /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/waitpid.html |
| | 2764 | pub extern fn waitpid(pid: pid_t, stat_loc: ?*c_int, options: c_int) pid_t; |
| | 2765 | |
| 2762 | /// int wctob(wint_t c); | 2766 | /// int wctob(wint_t c); |
| 2763 | /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/wctob.html | 2767 | /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/wctob.html |
| 2764 | pub extern fn wctob(c: wint_t) c_int; | 2768 | pub extern fn wctob(c: wint_t) c_int; |
| ... | @@ -3271,6 +3275,40 @@ pub const POLL = struct { | ... | @@ -3271,6 +3275,40 @@ pub const POLL = struct { |
| 3271 | pub const RDHUP = 0x2000; | 3275 | pub const RDHUP = 0x2000; |
| 3272 | }; | 3276 | }; |
| 3273 | | 3277 | |
| | 3278 | pub const W = struct { |
| | 3279 | pub const NOHANG = 1; |
| | 3280 | pub const UNTRACED = 2; |
| | 3281 | pub const STOPPED = 2; |
| | 3282 | pub const EXITED = 4; |
| | 3283 | pub const CONTINUED = 8; |
| | 3284 | pub const NOWAIT = 0x1000000; |
| | 3285 | |
| | 3286 | pub fn EXITSTATUS(s: c_int) u8 { |
| | 3287 | return @intCast((s & 0xff00) >> 8); |
| | 3288 | } |
| | 3289 | pub fn TERMSIG(s: c_int) u8 { |
| | 3290 | return @intCast(s & 0x7f); |
| | 3291 | } |
| | 3292 | pub fn STOPSIG(s: c_int) u8 { |
| | 3293 | return EXITSTATUS(s); |
| | 3294 | } |
| | 3295 | pub fn COREDUMP(s: c_int) c_uint { |
| | 3296 | return s & 0x80; |
| | 3297 | } |
| | 3298 | pub fn IFEXITED(s: c_int) bool { |
| | 3299 | return TERMSIG(s) == 0; |
| | 3300 | } |
| | 3301 | pub fn IFSTOPPED(s: c_int) bool { |
| | 3302 | return ((s & 0xffff) *% 0x10001) >> 8 > 0x7f00; |
| | 3303 | } |
| | 3304 | pub fn IFSIGNALED(s: c_int) bool { |
| | 3305 | return s & 0xffff -% 1 < 0xff; |
| | 3306 | } |
| | 3307 | pub fn IFCONTINUED(s: c_int) bool { |
| | 3308 | return s == 0xffff; |
| | 3309 | } |
| | 3310 | }; |
| | 3311 | |
| 3274 | pub fn getpid() pid_t { | 3312 | pub fn getpid() pid_t { |
| 3275 | return libc.getpid(); | 3313 | return libc.getpid(); |
| 3276 | } | 3314 | } |
| ... | @@ -3646,3 +3684,10 @@ pub fn poll(fds: []struct_pollfd, timeout_ms: c_int) !c_int { | ... | @@ -3646,3 +3684,10 @@ pub fn poll(fds: []struct_pollfd, timeout_ms: c_int) !c_int { |
| 3646 | std.debug.assert(rc >= 0); | 3684 | std.debug.assert(rc >= 0); |
| 3647 | return rc; | 3685 | return rc; |
| 3648 | } | 3686 | } |
| | 3687 | pub fn waitpid(pid: pid_t, options: c_int) !struct { pid_t, c_int } { |
| | 3688 | var status: c_int = 0; |
| | 3689 | const rc = libc.waitpid(pid, &status, options); |
| | 3690 | if (rc == -1) return errno.fromInt(errno.fromLibC()); |
| | 3691 | std.debug.assert(rc >= 0); |
| | 3692 | return .{ rc, status }; |
| | 3693 | } |