Commit 5582d20f04

Malcolm Still <malcolm.still@gmail.com>
2021-07-10 22:56:41
Add waitid syscall on linux (#9335)
1 parent 13aedf0
Changed files (2)
lib
std
lib/std/os/bits/linux.zig
@@ -203,6 +203,15 @@ pub const WEXITED = 4;
 pub const WCONTINUED = 8;
 pub const WNOWAIT = 0x1000000;
 
+// waitid id types
+pub const P = enum(c_uint) {
+    ALL = 0,
+    PID = 1,
+    PGID = 2,
+    PIDFD = 3,
+    _,
+};
+
 pub usingnamespace if (is_mips)
     struct {
         pub const SA_NOCLDSTOP = 1;
lib/std/os/linux.zig
@@ -705,6 +705,10 @@ pub fn waitpid(pid: pid_t, status: *u32, flags: u32) usize {
     return syscall4(.wait4, @bitCast(usize, @as(isize, pid)), @ptrToInt(status), flags, 0);
 }
 
+pub fn waitid(id_type: P, id: i32, infop: *siginfo_t, flags: u32) usize {
+    return syscall5(.waitid, @enumToInt(id_type), @bitCast(usize, @as(isize, id)), @ptrToInt(infop), flags, 0);
+}
+
 pub fn fcntl(fd: fd_t, cmd: i32, arg: usize) usize {
     return syscall3(.fcntl, @bitCast(usize, @as(isize, fd)), @bitCast(usize, @as(isize, cmd)), arg);
 }