summaryrefslogtreecommitdiffstats
path: root/vendor/rustix/src/process
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/rustix/src/process')
-rw-r--r--vendor/rustix/src/process/chdir.rs11
-rw-r--r--vendor/rustix/src/process/id.rs3
-rw-r--r--vendor/rustix/src/process/ioctl.rs2
-rw-r--r--vendor/rustix/src/process/kill.rs4
-rw-r--r--vendor/rustix/src/process/membarrier.rs2
-rw-r--r--vendor/rustix/src/process/mod.rs15
-rw-r--r--vendor/rustix/src/process/pidfd.rs2
-rw-r--r--vendor/rustix/src/process/pidfd_getfd.rs2
-rw-r--r--vendor/rustix/src/process/prctl.rs37
-rw-r--r--vendor/rustix/src/process/procctl.rs15
-rw-r--r--vendor/rustix/src/process/sched.rs4
-rw-r--r--vendor/rustix/src/process/wait.rs90
12 files changed, 116 insertions, 71 deletions
diff --git a/vendor/rustix/src/process/chdir.rs b/vendor/rustix/src/process/chdir.rs
index b110afef8..a68352f0e 100644
--- a/vendor/rustix/src/process/chdir.rs
+++ b/vendor/rustix/src/process/chdir.rs
@@ -67,15 +67,18 @@ fn _getcwd(mut buffer: Vec<u8>) -> io::Result<CString> {
loop {
match backend::process::syscalls::getcwd(buffer.spare_capacity_mut()) {
Err(io::Errno::RANGE) => {
- buffer.reserve(buffer.capacity() + 1); // use `Vec` reallocation strategy to grow capacity exponentially
+ // Use `Vec` reallocation strategy to grow capacity
+ // exponentially.
+ buffer.reserve(buffer.capacity() + 1);
}
Ok(_) => {
// SAFETY:
// - "These functions return a null-terminated string"
- // - [POSIX definition 3.375: String]: "A contiguous sequence of bytes
- // terminated by and including the first null byte."
+ // - [POSIX definition 3.375: String]: "A contiguous sequence
+ // of bytes terminated by and including the first null byte."
//
- // Thus, there will be a single NUL byte at the end of the string.
+ // Thus, there will be a single NUL byte at the end of the
+ // string.
//
// [POSIX definition 3.375: String]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_375
unsafe {
diff --git a/vendor/rustix/src/process/id.rs b/vendor/rustix/src/process/id.rs
index 4ed33a6c8..1a49dc539 100644
--- a/vendor/rustix/src/process/id.rs
+++ b/vendor/rustix/src/process/id.rs
@@ -225,7 +225,8 @@ pub fn getgroups() -> io::Result<Vec<Gid>> {
buffer.resize(ngroups, Gid::ROOT);
return Ok(buffer);
}
- buffer.reserve(1); // use `Vec` reallocation strategy to grow capacity exponentially
+ // Use `Vec` reallocation strategy to grow capacity exponentially.
+ buffer.reserve(1);
buffer.resize(buffer.capacity(), Gid::ROOT);
}
}
diff --git a/vendor/rustix/src/process/ioctl.rs b/vendor/rustix/src/process/ioctl.rs
index 3c9d90255..5afc76609 100644
--- a/vendor/rustix/src/process/ioctl.rs
+++ b/vendor/rustix/src/process/ioctl.rs
@@ -10,7 +10,7 @@ use crate::{backend, io, ioctl};
use backend::c;
use backend::fd::AsFd;
-/// `ioctl(fd, TIOCSCTTY, 0)`—Sets the controlling terminal for the processs.
+/// `ioctl(fd, TIOCSCTTY, 0)`—Sets the controlling terminal for the process.
///
/// # References
/// - [Linux]
diff --git a/vendor/rustix/src/process/kill.rs b/vendor/rustix/src/process/kill.rs
index 5f6f06c48..01d5380f8 100644
--- a/vendor/rustix/src/process/kill.rs
+++ b/vendor/rustix/src/process/kill.rs
@@ -19,8 +19,8 @@ pub fn kill_process(pid: Pid, sig: Signal) -> io::Result<()> {
/// `kill(-pid, sig)`—Sends a signal to all processes in a process group.
///
-/// If `pid` is 1, this sends a signal to all processes the current process
-/// has permission to send signals to, except process `1`, possibly other
+/// If `pid` is 1, this sends a signal to all processes the current process has
+/// permission to send signals to, except process `1`, possibly other
/// system-specific processes, and on some systems, the current process.
///
/// # References
diff --git a/vendor/rustix/src/process/membarrier.rs b/vendor/rustix/src/process/membarrier.rs
index 9c42bbd85..26be07dd9 100644
--- a/vendor/rustix/src/process/membarrier.rs
+++ b/vendor/rustix/src/process/membarrier.rs
@@ -35,7 +35,7 @@ bitflags::bitflags! {
/// `MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ` (since Linux 5.10)
const REGISTER_PRIVATE_EXPEDITED_RSEQ = MembarrierCommand::RegisterPrivateExpeditedRseq as _;
- /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
const _ = !0;
}
}
diff --git a/vendor/rustix/src/process/mod.rs b/vendor/rustix/src/process/mod.rs
index 55eed1ac8..195216c3a 100644
--- a/vendor/rustix/src/process/mod.rs
+++ b/vendor/rustix/src/process/mod.rs
@@ -7,7 +7,7 @@ mod chroot;
mod exit;
#[cfg(not(target_os = "wasi"))] // WASI doesn't have get[gpu]id.
mod id;
-#[cfg(not(any(target_os = "aix", target_os = "espidf")))]
+#[cfg(not(any(target_os = "aix", target_os = "espidf", target_os = "vita")))]
mod ioctl;
#[cfg(not(any(target_os = "espidf", target_os = "wasi")))]
mod kill;
@@ -19,7 +19,8 @@ mod pidfd;
mod pidfd_getfd;
#[cfg(linux_kernel)]
mod prctl;
-#[cfg(not(any(target_os = "fuchsia", target_os = "wasi")))] // WASI doesn't have [gs]etpriority.
+#[cfg(not(any(target_os = "fuchsia", target_os = "vita", target_os = "wasi")))]
+// WASI doesn't have [gs]etpriority.
mod priority;
#[cfg(freebsdlike)]
mod procctl;
@@ -27,6 +28,7 @@ mod procctl;
target_os = "espidf",
target_os = "fuchsia",
target_os = "redox",
+ target_os = "vita",
target_os = "wasi"
)))]
mod rlimit;
@@ -35,7 +37,7 @@ mod sched;
mod sched_yield;
#[cfg(not(target_os = "wasi"))] // WASI doesn't have umask.
mod umask;
-#[cfg(not(any(target_os = "espidf", target_os = "wasi")))]
+#[cfg(not(any(target_os = "espidf", target_os = "vita", target_os = "wasi")))]
mod wait;
#[cfg(not(target_os = "wasi"))]
@@ -45,7 +47,7 @@ pub use chroot::*;
pub use exit::*;
#[cfg(not(target_os = "wasi"))]
pub use id::*;
-#[cfg(not(any(target_os = "aix", target_os = "espidf")))]
+#[cfg(not(any(target_os = "aix", target_os = "espidf", target_os = "vita")))]
pub use ioctl::*;
#[cfg(not(any(target_os = "espidf", target_os = "wasi")))]
pub use kill::*;
@@ -57,7 +59,7 @@ pub use pidfd::*;
pub use pidfd_getfd::*;
#[cfg(linux_kernel)]
pub use prctl::*;
-#[cfg(not(any(target_os = "fuchsia", target_os = "wasi")))]
+#[cfg(not(any(target_os = "fuchsia", target_os = "vita", target_os = "wasi")))]
pub use priority::*;
#[cfg(freebsdlike)]
pub use procctl::*;
@@ -65,6 +67,7 @@ pub use procctl::*;
target_os = "espidf",
target_os = "fuchsia",
target_os = "redox",
+ target_os = "vita",
target_os = "wasi"
)))]
pub use rlimit::*;
@@ -73,5 +76,5 @@ pub use sched::*;
pub use sched_yield::sched_yield;
#[cfg(not(target_os = "wasi"))]
pub use umask::*;
-#[cfg(not(any(target_os = "espidf", target_os = "wasi")))]
+#[cfg(not(any(target_os = "espidf", target_os = "vita", target_os = "wasi")))]
pub use wait::*;
diff --git a/vendor/rustix/src/process/pidfd.rs b/vendor/rustix/src/process/pidfd.rs
index 0548055fc..abebaf21f 100644
--- a/vendor/rustix/src/process/pidfd.rs
+++ b/vendor/rustix/src/process/pidfd.rs
@@ -12,7 +12,7 @@ bitflags::bitflags! {
/// `PIDFD_NONBLOCK`.
const NONBLOCK = backend::c::PIDFD_NONBLOCK;
- /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
const _ = !0;
}
}
diff --git a/vendor/rustix/src/process/pidfd_getfd.rs b/vendor/rustix/src/process/pidfd_getfd.rs
index 27d4f1986..4c7696fb6 100644
--- a/vendor/rustix/src/process/pidfd_getfd.rs
+++ b/vendor/rustix/src/process/pidfd_getfd.rs
@@ -18,7 +18,7 @@ bitflags::bitflags! {
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct PidfdGetfdFlags: backend::c::c_uint {
- /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
const _ = !0;
}
}
diff --git a/vendor/rustix/src/process/prctl.rs b/vendor/rustix/src/process/prctl.rs
index 59be7020f..830abc13d 100644
--- a/vendor/rustix/src/process/prctl.rs
+++ b/vendor/rustix/src/process/prctl.rs
@@ -149,7 +149,7 @@ bitflags! {
#[doc(alias = "PR_UNALIGN_SIGBUS")]
const SIGBUS = 2;
- /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
const _ = !0;
}
}
@@ -410,8 +410,8 @@ const PR_SET_ENDIAN: c_int = 20;
///
/// # Safety
///
-/// Please ensure the conditions necessary to safely call this function,
-/// as detailed in the references above.
+/// Please ensure the conditions necessary to safely call this function, as
+/// detailed in the references above.
///
/// [`prctl(PR_SET_ENDIAN,...)`]: https://man7.org/linux/man-pages/man2/prctl.2.html
#[inline]
@@ -649,8 +649,8 @@ pub enum VirtualMemoryMapAddress {
///
/// # Safety
///
-/// Please ensure the conditions necessary to safely call this function,
-/// as detailed in the references above.
+/// Please ensure the conditions necessary to safely call this function, as
+/// detailed in the references above.
///
/// [`prctl(PR_SET_MM,...)`]: https://man7.org/linux/man-pages/man2/prctl.2.html
#[inline]
@@ -685,8 +685,8 @@ pub fn set_executable_file(fd: BorrowedFd<'_>) -> io::Result<()> {
///
/// # Safety
///
-/// Please ensure the conditions necessary to safely call this function,
-/// as detailed in the references above.
+/// Please ensure the conditions necessary to safely call this function, as
+/// detailed in the references above.
///
/// [`prctl(PR_SET_MM,PR_SET_MM_AUXV,...)`]: https://man7.org/linux/man-pages/man2/prctl.2.html
#[inline]
@@ -764,8 +764,8 @@ pub struct PrctlMmMap {
///
/// # Safety
///
-/// Please ensure the conditions necessary to safely call this function,
-/// as detailed in the references above.
+/// Please ensure the conditions necessary to safely call this function, as
+/// detailed in the references above.
///
/// [`prctl(PR_SET_MM,PR_SET_MM_MAP,...)`]: https://man7.org/linux/man-pages/man2/prctl.2.html
#[inline]
@@ -960,9 +960,11 @@ bitflags! {
const ENABLE = 1_u32 << 1;
/// The speculation feature is disabled, mitigation is enabled.
const DISABLE = 1_u32 << 2;
- /// The speculation feature is disabled, mitigation is enabled, and it cannot be undone.
+ /// The speculation feature is disabled, mitigation is enabled, and it
+ /// cannot be undone.
const FORCE_DISABLE = 1_u32 << 3;
- /// The speculation feature is disabled, mitigation is enabled, and the state will be cleared on `execve`.
+ /// The speculation feature is disabled, mitigation is enabled, and the
+ /// state will be cleared on `execve`.
const DISABLE_NOEXEC = 1_u32 << 4;
}
}
@@ -972,15 +974,18 @@ bitflags! {
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct SpeculationFeatureState: u32 {
- /// Mitigation can be controlled per thread by `PR_SET_SPECULATION_CTRL`.
+ /// Mitigation can be controlled per thread by
+ /// `PR_SET_SPECULATION_CTRL`.
const PRCTL = 1_u32 << 0;
/// The speculation feature is enabled, mitigation is disabled.
const ENABLE = 1_u32 << 1;
/// The speculation feature is disabled, mitigation is enabled.
const DISABLE = 1_u32 << 2;
- /// The speculation feature is disabled, mitigation is enabled, and it cannot be undone.
+ /// The speculation feature is disabled, mitigation is enabled, and it
+ /// cannot be undone.
const FORCE_DISABLE = 1_u32 << 3;
- /// The speculation feature is disabled, mitigation is enabled, and the state will be cleared on `execve`.
+ /// The speculation feature is disabled, mitigation is enabled, and the
+ /// state will be cleared on `execve`.
const DISABLE_NOEXEC = 1_u32 << 4;
}
}
@@ -1080,8 +1085,8 @@ const PR_PAC_SET_ENABLED_KEYS: c_int = 60;
///
/// # Safety
///
-/// Please ensure the conditions necessary to safely call this function,
-/// as detailed in the references above.
+/// Please ensure the conditions necessary to safely call this function, as
+/// detailed in the references above.
///
/// [`prctl(PR_PAC_SET_ENABLED_KEYS,...)`]: https://www.kernel.org/doc/html/v5.18/arm64/pointer-authentication.html
#[inline]
diff --git a/vendor/rustix/src/process/procctl.rs b/vendor/rustix/src/process/procctl.rs
index 5225f16f7..f06bd72d6 100644
--- a/vendor/rustix/src/process/procctl.rs
+++ b/vendor/rustix/src/process/procctl.rs
@@ -230,7 +230,7 @@ bitflags! {
/// The process is the root of the reaper tree (pid 1).
const REALINIT = 2;
- /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
const _ = !0;
}
}
@@ -300,7 +300,8 @@ bitflags! {
const REAPER = 4;
/// The reported process is in the zombie state.
const ZOMBIE = 8;
- /// The reported process is stopped by SIGSTOP/SIGTSTP.
+ /// The reported process is stopped by
+ /// [`Signal::Stop`]/[`Signal::Tstp`].
const STOPPED = 16;
/// The reported process is in the process of exiting.
const EXITING = 32;
@@ -493,12 +494,12 @@ const PROC_NO_NEW_PRIVS_CTL: c_int = 19;
const PROC_NO_NEW_PRIVS_ENABLE: c_int = 1;
-/// Enable the `no_new_privs` mode that ignores SUID and SGID bits
-/// on `execve` in the specified process and its future descendants.
+/// Enable the `no_new_privs` mode that ignores SUID and SGID bits on `execve`
+/// in the specified process and its future descendants.
///
-/// This is similar to `set_no_new_privs` on Linux, with the exception
-/// that on FreeBSD there is no argument `no_new_privs` argument as it's
-/// only possible to enable this mode and there's no going back.
+/// This is similar to `set_no_new_privs` on Linux, with the exception that on
+/// FreeBSD there is no argument `no_new_privs` argument as it's only possible
+/// to enable this mode and there's no going back.
///
/// # References
/// - [Linux: `prctl(PR_SET_NO_NEW_PRIVS,...)`]
diff --git a/vendor/rustix/src/process/sched.rs b/vendor/rustix/src/process/sched.rs
index 239b7df82..b7dcd58cc 100644
--- a/vendor/rustix/src/process/sched.rs
+++ b/vendor/rustix/src/process/sched.rs
@@ -80,8 +80,8 @@ impl Default for CpuSet {
/// `pid` is the thread ID to update. If pid is `None`, then the current thread
/// is updated.
///
-/// The `CpuSet` argument specifies the set of CPUs on which the thread will
-/// be eligible to run.
+/// The `CpuSet` argument specifies the set of CPUs on which the thread will be
+/// eligible to run.
///
/// # References
/// - [Linux]
diff --git a/vendor/rustix/src/process/wait.rs b/vendor/rustix/src/process/wait.rs
index b43bd03d6..ccb90ae43 100644
--- a/vendor/rustix/src/process/wait.rs
+++ b/vendor/rustix/src/process/wait.rs
@@ -9,7 +9,7 @@ use crate::fd::BorrowedFd;
use crate::backend::process::wait::SiginfoExt;
bitflags! {
- /// Options for modifying the behavior of wait/waitpid
+ /// Options for modifying the behavior of [`wait`]/[`waitpid`].
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct WaitOptions: u32 {
@@ -23,14 +23,14 @@ bitflags! {
/// [`Signal::Cont`].
const CONTINUED = bitcast!(backend::process::wait::WCONTINUED);
- /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
const _ = !0;
}
}
#[cfg(not(any(target_os = "openbsd", target_os = "redox", target_os = "wasi")))]
bitflags! {
- /// Options for modifying the behavior of waitid
+ /// Options for modifying the behavior of [`waitid`].
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct WaitidOptions: u32 {
@@ -46,7 +46,7 @@ bitflags! {
/// Wait for processes that have been stopped.
const STOPPED = bitcast!(backend::process::wait::WSTOPPED);
- /// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
+ /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
const _ = !0;
}
}
@@ -93,8 +93,8 @@ impl WaitStatus {
backend::process::wait::WIFCONTINUED(self.0 as _)
}
- /// Returns the number of the signal that stopped the process,
- /// if the process was stopped by a signal.
+ /// Returns the number of the signal that stopped the process, if the
+ /// process was stopped by a signal.
#[inline]
pub fn stopping_signal(self) -> Option<u32> {
if self.stopped() {
@@ -104,8 +104,8 @@ impl WaitStatus {
}
}
- /// Returns the exit status number returned by the process,
- /// if it exited normally.
+ /// Returns the exit status number returned by the process, if it exited
+ /// normally.
#[inline]
pub fn exit_status(self) -> Option<u32> {
if self.exited() {
@@ -115,8 +115,8 @@ impl WaitStatus {
}
}
- /// Returns the number of the signal that terminated the process,
- /// if the process was terminated by a signal.
+ /// Returns the number of the signal that terminated the process, if the
+ /// process was terminated by a signal.
#[inline]
pub fn terminating_signal(self) -> Option<u32> {
if self.signaled() {
@@ -153,15 +153,15 @@ impl WaitidStatus {
self.si_code() == backend::c::CLD_EXITED
}
- /// Returns whether the process was terminated by a signal
- /// and did not create a core file.
+ /// Returns whether the process was terminated by a signal and did not
+ /// create a core file.
#[inline]
pub fn killed(&self) -> bool {
self.si_code() == backend::c::CLD_KILLED
}
- /// Returns whether the process was terminated by a signal
- /// and did create a core file.
+ /// Returns whether the process was terminated by a signal and did create a
+ /// core file.
#[inline]
pub fn dumped(&self) -> bool {
self.si_code() == backend::c::CLD_DUMPED
@@ -173,8 +173,8 @@ impl WaitidStatus {
self.si_code() == backend::c::CLD_CONTINUED
}
- /// Returns the number of the signal that stopped the process,
- /// if the process was stopped by a signal.
+ /// Returns the number of the signal that stopped the process, if the
+ /// process was stopped by a signal.
#[inline]
#[cfg(not(any(target_os = "emscripten", target_os = "fuchsia", target_os = "netbsd")))]
pub fn stopping_signal(&self) -> Option<u32> {
@@ -185,8 +185,8 @@ impl WaitidStatus {
}
}
- /// Returns the number of the signal that trapped the process,
- /// if the process was trapped by a signal.
+ /// Returns the number of the signal that trapped the process, if the
+ /// process was trapped by a signal.
#[inline]
#[cfg(not(any(target_os = "emscripten", target_os = "fuchsia", target_os = "netbsd")))]
pub fn trapping_signal(&self) -> Option<u32> {
@@ -197,8 +197,8 @@ impl WaitidStatus {
}
}
- /// Returns the exit status number returned by the process,
- /// if it exited normally.
+ /// Returns the exit status number returned by the process, if it exited
+ /// normally.
#[inline]
#[cfg(not(any(target_os = "emscripten", target_os = "fuchsia", target_os = "netbsd")))]
pub fn exit_status(&self) -> Option<u32> {
@@ -209,8 +209,8 @@ impl WaitidStatus {
}
}
- /// Returns the number of the signal that terminated the process,
- /// if the process was terminated by a signal.
+ /// Returns the number of the signal that terminated the process, if the
+ /// process was terminated by a signal.
#[inline]
#[cfg(not(any(target_os = "emscripten", target_os = "fuchsia", target_os = "netbsd")))]
pub fn terminating_signal(&self) -> Option<u32> {
@@ -254,20 +254,26 @@ impl WaitidStatus {
#[non_exhaustive]
pub enum WaitId<'a> {
/// Wait on all processes.
+ #[doc(alias = "P_ALL")]
All,
/// Wait for a specific process ID.
+ #[doc(alias = "P_PID")]
Pid(Pid),
+ /// Wait for a specific process group ID, or the calling process' group ID.
+ #[doc(alias = "P_PGID")]
+ Pgid(Option<Pid>),
+
/// Wait for a specific process file descriptor.
#[cfg(target_os = "linux")]
+ #[doc(alias = "P_PIDFD")]
PidFd(BorrowedFd<'a>),
/// Eat the lifetime for non-Linux platforms.
#[doc(hidden)]
#[cfg(not(target_os = "linux"))]
__EatLifetime(core::marker::PhantomData<&'a ()>),
- // TODO(notgull): Once this crate has the concept of PGIDs, add a WaitId::Pgid
}
/// `waitpid(pid, waitopts)`—Wait for a specific process to change state.
@@ -275,12 +281,6 @@ pub enum WaitId<'a> {
/// If the pid is `None`, the call will wait for any child process whose
/// process group id matches that of the calling process.
///
-/// If the pid is equal to `RawPid::MAX`, the call will wait for any child
-/// process.
-///
-/// Otherwise if the `wrapping_neg` of pid is less than pid, the call will wait
-/// for any child process with a group ID equal to the `wrapping_neg` of `pid`.
-///
/// Otherwise, the call will wait for the child process with the given pid.
///
/// On Success, returns the status of the selected process.
@@ -288,6 +288,16 @@ pub enum WaitId<'a> {
/// If `NOHANG` was specified in the options, and the selected child process
/// didn't change state, returns `None`.
///
+/// # Bugs
+///
+/// This function does not currently support waiting for given process group
+/// (the < 0 case of `waitpid`); to do that, currently the [`waitpgid`] or
+/// [`waitid`] function must be used.
+///
+/// This function does not currently support waiting for any process (the
+/// `-1` case of `waitpid`); to do that, currently the [`wait`] function must
+/// be used.
+///
/// # References
/// - [POSIX]
/// - [Linux]
@@ -300,6 +310,28 @@ pub fn waitpid(pid: Option<Pid>, waitopts: WaitOptions) -> io::Result<Option<Wai
Ok(backend::process::syscalls::waitpid(pid, waitopts)?.map(|(_, status)| status))
}
+/// `waitpid(-pgid, waitopts)`—Wait for a process in a specific process group
+/// to change state.
+///
+/// The call will wait for any child process with the given pgid.
+///
+/// On Success, returns the status of the selected process.
+///
+/// If `NOHANG` was specified in the options, and no selected child process
+/// changed state, returns `None`.
+///
+/// # References
+/// - [POSIX]
+/// - [Linux]
+///
+/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/wait.html
+/// [Linux]: https://man7.org/linux/man-pages/man2/waitpid.2.html
+#[cfg(not(target_os = "wasi"))]
+#[inline]
+pub fn waitpgid(pgid: Pid, waitopts: WaitOptions) -> io::Result<Option<WaitStatus>> {
+ Ok(backend::process::syscalls::waitpgid(pgid, waitopts)?.map(|(_, status)| status))
+}
+
/// `wait(waitopts)`—Wait for any of the children of calling process to
/// change state.
///