Add waitid syscall on linux (#9335)

This commit is contained in:
Malcolm Still
2021-07-10 21:56:41 +01:00
committed by Andrew Kelley
parent 13aedf09d6
commit 5582d20f04
2 changed files with 13 additions and 0 deletions

View File

@@ -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;

View File

@@ -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);
}