diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 0eaaced03ec2a..a4b6c9b4e86f2 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -21,6 +21,7 @@ pub type tcflag_t = ::c_ulong; pub type nl_item = ::c_int; pub type id_t = ::c_uint; pub type sem_t = ::c_int; +pub type idtype_t = ::c_uint; pub enum timezone {} @@ -1363,6 +1364,15 @@ pub const LIO_READ: ::c_int = 1; pub const LIO_WAIT: ::c_int = 2; pub const LIO_NOWAIT: ::c_int = 1; +pub const WEXITED: ::c_int = 0x00000004; +pub const WSTOPPED: ::c_int = 0x00000008; +pub const WCONTINUED: ::c_int = 0x00000010; +pub const WNOWAIT: ::c_int = 0x00000020; + +pub const P_ALL: idtype_t = 0; +pub const P_PID: idtype_t = 1; +pub const P_PGID: idtype_t = 2; + f! { pub fn WSTOPSIG(status: ::c_int) -> ::c_int { status >> 8 @@ -1532,6 +1542,12 @@ extern { flags: ::c_int) -> ::c_int; pub fn initgroups(user: *const ::c_char, basegroup: ::c_int) -> ::c_int; + + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "waitid$UNIX2003")] + pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t, + options: ::c_int) -> ::c_int; + } cfg_if! { diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index ba56d1e13e781..4d5a4cfa0d676 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -9,6 +9,7 @@ pub type sem_t = _sem; pub type fsblkcnt_t = ::uint64_t; pub type fsfilcnt_t = ::uint64_t; +pub type idtype_t = ::c_uint; s! { pub struct utmpx { @@ -356,6 +357,18 @@ pub const LC_ALL_MASK: ::c_int = LC_COLLATE_MASK | LC_NUMERIC_MASK | LC_TIME_MASK; +pub const WSTOPPED: ::c_int = 2; // same as WUNTRACED +pub const WCONTINUED: ::c_int = 4; +pub const WNOWAIT: ::c_int = 8; +pub const WEXITED: ::c_int = 16; +pub const WTRAPPED: ::c_int = 32; + +// FreeBSD defines a great many more of these, we only expose the +// standardized ones. +pub const P_PID: idtype_t = 0; +pub const P_PGID: idtype_t = 2; +pub const P_ALL: idtype_t = 7; + extern { pub fn __error() -> *mut ::c_int; @@ -382,6 +395,8 @@ extern { timeout: *mut ::timespec) -> ::ssize_t; pub fn freelocale(loc: ::locale_t) -> ::c_int; + pub fn waitid(idtype: idtype_t, id: ::id_t, infop: *mut ::siginfo_t, + options: ::c_int) -> ::c_int; } cfg_if! { diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 57a34130c919c..2f85513408b2f 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -4,6 +4,7 @@ pub type dev_t = u64; pub type blksize_t = ::int32_t; pub type fsblkcnt_t = ::uint64_t; pub type fsfilcnt_t = ::uint64_t; +pub type idtype_t = ::c_int; s! { pub struct aiocb { @@ -583,6 +584,15 @@ pub const SIGEV_NONE: ::c_int = 0; pub const SIGEV_SIGNAL: ::c_int = 1; pub const SIGEV_THREAD: ::c_int = 2; +pub const WSTOPPED: ::c_int = 0x00000002; // same as WUNTRACED +pub const WCONTINUED: ::c_int = 0x00000010; +pub const WEXITED: ::c_int = 0x000000020; +pub const WNOWAIT: ::c_int = 0x00010000; + +pub const P_ALL: idtype_t = 0; +pub const P_PID: idtype_t = 1; +pub const P_PGID: idtype_t = 4; + extern { pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int; pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int; diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index ab53e6c788c68..86e590912857d 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -28,6 +28,8 @@ pub type fsblkcnt_t = i64; pub type fsfilcnt_t = i64; pub type pthread_attr_t = *mut ::c_void; pub type nl_item = ::c_int; +pub type id_t = i32; +pub type idtype_t = ::c_uint; pub enum timezone {} @@ -670,6 +672,17 @@ pub const SO_PEERCRED: ::c_int = 0x4000000b; pub const NI_MAXHOST: ::size_t = 1025; +pub const WNOHANG: ::c_int = 0x01; +pub const WUNTRACED: ::c_int = 0x02; +pub const WCONTINUED: ::c_int = 0x04; +pub const WEXITED: ::c_int = 0x08; +pub const WSTOPPED: ::c_int = 0x10; +pub const WNOWAIT: ::c_int = 0x20; + +pub const P_ALL: idtype_t = 0; +pub const P_PID: idtype_t = 1; +pub const P_PGID: idtype_t = 2; + f! { pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () { let fd = fd as usize; @@ -742,6 +755,8 @@ extern { flags: ::c_int) -> ::c_int; pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t, abstime: *const ::timespec) -> ::c_int; + pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t, + options: ::c_int) -> ::c_int; } cfg_if! { diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs index 8a1b565d620fe..4b4e26222ad62 100644 --- a/src/unix/notbsd/android/mod.rs +++ b/src/unix/notbsd/android/mod.rs @@ -25,6 +25,7 @@ pub type rlim_t = ::c_ulong; pub type dev_t = ::c_ulong; pub type ino_t = ::c_ulong; pub type __CPU_BITTYPE = ::c_ulong; +pub type idtype_t = ::c_int; s! { pub struct dirent { diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index f822a2faa2cfe..13b61df2cde06 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -17,6 +17,7 @@ pub type msgqnum_t = ::c_ulong; pub type msglen_t = ::c_ulong; pub type nfds_t = ::c_ulong; pub type nl_item = ::c_int; +pub type idtype_t = ::c_uint; pub enum fpos64_t {} // TODO: fill this out with a struct diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index 39ad6d79c0d76..0233d266e917e 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -624,6 +624,10 @@ pub const SIGEV_SIGNAL: ::c_int = 0; pub const SIGEV_NONE: ::c_int = 1; pub const SIGEV_THREAD: ::c_int = 2; +pub const P_ALL: idtype_t = 0; +pub const P_PID: idtype_t = 1; +pub const P_PGID: idtype_t = 2; + f! { pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () { let fd = fd as usize; @@ -851,6 +855,8 @@ extern { buf: *mut ::c_char, buflen: ::size_t) -> ::c_int; pub fn clearenv() -> ::c_int; + pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t, + options: ::c_int) -> ::c_int; } cfg_if! { diff --git a/src/unix/solaris/mod.rs b/src/unix/solaris/mod.rs index 3810fc57f2132..b604208583a40 100644 --- a/src/unix/solaris/mod.rs +++ b/src/unix/solaris/mod.rs @@ -32,6 +32,8 @@ pub type pthread_key_t = ::c_uint; pub type blksize_t = u32; pub type fflags_t = u32; pub type nl_item = ::c_int; +pub type id_t = ::c_int; +pub type idtype_t = ::c_uint; pub enum timezone {} @@ -550,6 +552,18 @@ pub const SIGXFSZ: ::c_int = 31; pub const WNOHANG: ::c_int = 0x40; pub const WUNTRACED: ::c_int = 0x04; +pub const WEXITED: ::c_int = 0x01; +pub const WTRAPPED: ::c_int = 0x02; +pub const WSTOPPED: ::c_int = WUNTRACED; +pub const WCONTINUED: ::c_int = 0x08; +pub const WNOWAIT: ::c_int = 0x80; + +// Solaris defines a great many more of these; we only expose the +// standardized ones. +pub const P_PID: idtype_t = 0; +pub const P_PGID: idtype_t = 2; +pub const P_ALL: idtype_t = 7; + pub const PROT_NONE: ::c_int = 0; pub const PROT_READ: ::c_int = 1; pub const PROT_WRITE: ::c_int = 2; @@ -1056,4 +1070,6 @@ extern { abstime: *const ::timespec) -> ::c_int; pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t, abstime: *const ::timespec) -> ::c_int; + pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t, + options: ::c_int) -> ::c_int; }