summaryrefslogtreecommitdiffstats
path: root/vendor/rustix/src/backend/libc/process
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:32 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:32 +0000
commit4547b622d8d29df964fa2914213088b148c498fc (patch)
tree9fc6b25f3c3add6b745be9a2400a6e96140046e9 /vendor/rustix/src/backend/libc/process
parentReleasing progress-linux version 1.66.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-4547b622d8d29df964fa2914213088b148c498fc.tar.xz
rustc-4547b622d8d29df964fa2914213088b148c498fc.zip
Merging upstream version 1.67.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/rustix/src/backend/libc/process')
-rw-r--r--vendor/rustix/src/backend/libc/process/cpu_set.rs49
-rw-r--r--vendor/rustix/src/backend/libc/process/mod.rs12
-rw-r--r--vendor/rustix/src/backend/libc/process/syscalls.rs465
-rw-r--r--vendor/rustix/src/backend/libc/process/types.rs414
-rw-r--r--vendor/rustix/src/backend/libc/process/wait.rs6
5 files changed, 946 insertions, 0 deletions
diff --git a/vendor/rustix/src/backend/libc/process/cpu_set.rs b/vendor/rustix/src/backend/libc/process/cpu_set.rs
new file mode 100644
index 000000000..14ad8d208
--- /dev/null
+++ b/vendor/rustix/src/backend/libc/process/cpu_set.rs
@@ -0,0 +1,49 @@
+#![allow(non_snake_case)]
+
+use super::super::c;
+use super::types::{RawCpuSet, CPU_SETSIZE};
+
+#[inline]
+pub(crate) fn CPU_SET(cpu: usize, cpuset: &mut RawCpuSet) {
+ assert!(
+ cpu < CPU_SETSIZE,
+ "cpu out of bounds: the cpu max is {} but the cpu is {}",
+ CPU_SETSIZE,
+ cpu
+ );
+ unsafe { c::CPU_SET(cpu, cpuset) }
+}
+
+#[inline]
+pub(crate) fn CPU_ZERO(cpuset: &mut RawCpuSet) {
+ unsafe { c::CPU_ZERO(cpuset) }
+}
+
+#[inline]
+pub(crate) fn CPU_CLR(cpu: usize, cpuset: &mut RawCpuSet) {
+ assert!(
+ cpu < CPU_SETSIZE,
+ "cpu out of bounds: the cpu max is {} but the cpu is {}",
+ CPU_SETSIZE,
+ cpu
+ );
+ unsafe { c::CPU_CLR(cpu, cpuset) }
+}
+
+#[inline]
+pub(crate) fn CPU_ISSET(cpu: usize, cpuset: &RawCpuSet) -> bool {
+ assert!(
+ cpu < CPU_SETSIZE,
+ "cpu out of bounds: the cpu max is {} but the cpu is {}",
+ CPU_SETSIZE,
+ cpu
+ );
+ unsafe { c::CPU_ISSET(cpu, cpuset) }
+}
+
+#[cfg(any(target_os = "android", target_os = "linux"))]
+#[inline]
+pub(crate) fn CPU_COUNT(cpuset: &RawCpuSet) -> u32 {
+ use core::convert::TryInto;
+ unsafe { c::CPU_COUNT(cpuset).try_into().unwrap() }
+}
diff --git a/vendor/rustix/src/backend/libc/process/mod.rs b/vendor/rustix/src/backend/libc/process/mod.rs
new file mode 100644
index 000000000..8675c1af9
--- /dev/null
+++ b/vendor/rustix/src/backend/libc/process/mod.rs
@@ -0,0 +1,12 @@
+#[cfg(any(
+ target_os = "android",
+ target_os = "dragonfly",
+ target_os = "fuchsia",
+ target_os = "linux",
+))]
+pub(crate) mod cpu_set;
+#[cfg(not(windows))]
+pub(crate) mod syscalls;
+pub(crate) mod types;
+#[cfg(not(target_os = "wasi"))]
+pub(crate) mod wait;
diff --git a/vendor/rustix/src/backend/libc/process/syscalls.rs b/vendor/rustix/src/backend/libc/process/syscalls.rs
new file mode 100644
index 000000000..6f4e85916
--- /dev/null
+++ b/vendor/rustix/src/backend/libc/process/syscalls.rs
@@ -0,0 +1,465 @@
+//! libc syscalls supporting `rustix::process`.
+
+use super::super::c;
+#[cfg(not(any(target_os = "wasi", target_os = "fuchsia")))]
+use super::super::conv::borrowed_fd;
+#[cfg(not(target_os = "wasi"))]
+use super::super::conv::ret_pid_t;
+use super::super::conv::{c_str, ret, ret_c_int, ret_discarded_char_ptr};
+#[cfg(any(target_os = "android", target_os = "linux"))]
+use super::super::conv::{syscall_ret, syscall_ret_u32};
+#[cfg(any(
+ target_os = "android",
+ target_os = "dragonfly",
+ target_os = "fuchsia",
+ target_os = "linux",
+))]
+use super::types::RawCpuSet;
+#[cfg(not(any(target_os = "wasi", target_os = "fuchsia")))]
+use crate::fd::BorrowedFd;
+use crate::ffi::CStr;
+use crate::io;
+use core::mem::MaybeUninit;
+#[cfg(not(any(target_os = "fuchsia", target_os = "redox", target_os = "wasi")))]
+use {
+ super::super::conv::ret_infallible,
+ super::super::offset::{libc_getrlimit, libc_rlimit, libc_setrlimit, LIBC_RLIM_INFINITY},
+ crate::process::{Resource, Rlimit},
+ core::convert::TryInto,
+};
+#[cfg(any(target_os = "android", target_os = "linux"))]
+use {
+ super::super::offset::libc_prlimit,
+ crate::process::{Cpuid, MembarrierCommand, MembarrierQuery},
+};
+#[cfg(not(target_os = "wasi"))]
+use {
+ super::types::RawUname,
+ crate::process::{Gid, Pid, RawNonZeroPid, RawPid, Signal, Uid, WaitOptions, WaitStatus},
+};
+
+#[cfg(not(target_os = "wasi"))]
+pub(crate) fn chdir(path: &CStr) -> io::Result<()> {
+ unsafe { ret(c::chdir(c_str(path))) }
+}
+
+#[cfg(not(any(target_os = "wasi", target_os = "fuchsia")))]
+pub(crate) fn fchdir(dirfd: BorrowedFd<'_>) -> io::Result<()> {
+ unsafe { ret(c::fchdir(borrowed_fd(dirfd))) }
+}
+
+#[cfg(not(target_os = "wasi"))]
+pub(crate) fn getcwd(buf: &mut [u8]) -> io::Result<()> {
+ unsafe { ret_discarded_char_ptr(c::getcwd(buf.as_mut_ptr().cast(), buf.len())) }
+}
+
+#[cfg(any(target_os = "android", target_os = "linux"))]
+pub(crate) fn membarrier_query() -> MembarrierQuery {
+ // GLIBC does not have a wrapper for `membarrier`; [the documentation]
+ // says to use `syscall`.
+ //
+ // [the documentation]: https://man7.org/linux/man-pages/man2/membarrier.2.html#NOTES
+ const MEMBARRIER_CMD_QUERY: u32 = 0;
+ unsafe {
+ match syscall_ret_u32(c::syscall(c::SYS_membarrier, MEMBARRIER_CMD_QUERY, 0)) {
+ Ok(query) => MembarrierQuery::from_bits_unchecked(query),
+ Err(_) => MembarrierQuery::empty(),
+ }
+ }
+}
+
+#[cfg(any(target_os = "android", target_os = "linux"))]
+pub(crate) fn membarrier(cmd: MembarrierCommand) -> io::Result<()> {
+ unsafe { syscall_ret(c::syscall(c::SYS_membarrier, cmd as u32, 0)) }
+}
+
+#[cfg(any(target_os = "android", target_os = "linux"))]
+pub(crate) fn membarrier_cpu(cmd: MembarrierCommand, cpu: Cpuid) -> io::Result<()> {
+ const MEMBARRIER_CMD_FLAG_CPU: u32 = 1;
+ unsafe {
+ syscall_ret(c::syscall(
+ c::SYS_membarrier,
+ cmd as u32,
+ MEMBARRIER_CMD_FLAG_CPU,
+ cpu.as_raw(),
+ ))
+ }
+}
+
+#[cfg(not(target_os = "wasi"))]
+#[inline]
+#[must_use]
+pub(crate) fn getuid() -> Uid {
+ unsafe {
+ let uid = c::getuid();
+ Uid::from_raw(uid)
+ }
+}
+
+#[cfg(not(target_os = "wasi"))]
+#[inline]
+#[must_use]
+pub(crate) fn geteuid() -> Uid {
+ unsafe {
+ let uid = c::geteuid();
+ Uid::from_raw(uid)
+ }
+}
+
+#[cfg(not(target_os = "wasi"))]
+#[inline]
+#[must_use]
+pub(crate) fn getgid() -> Gid {
+ unsafe {
+ let gid = c::getgid();
+ Gid::from_raw(gid)
+ }
+}
+
+#[cfg(not(target_os = "wasi"))]
+#[inline]
+#[must_use]
+pub(crate) fn getegid() -> Gid {
+ unsafe {
+ let gid = c::getegid();
+ Gid::from_raw(gid)
+ }
+}
+
+#[cfg(not(target_os = "wasi"))]
+#[inline]
+#[must_use]
+pub(crate) fn getpid() -> Pid {
+ unsafe {
+ let pid = c::getpid();
+ debug_assert_ne!(pid, 0);
+ Pid::from_raw_nonzero(RawNonZeroPid::new_unchecked(pid))
+ }
+}
+
+#[cfg(not(target_os = "wasi"))]
+#[inline]
+#[must_use]
+pub(crate) fn getppid() -> Option<Pid> {
+ unsafe {
+ let pid: i32 = c::getppid();
+ Pid::from_raw(pid)
+ }
+}
+
+#[cfg(not(target_os = "wasi"))]
+#[inline]
+pub(crate) fn getpgid(pid: Option<Pid>) -> io::Result<Pid> {
+ unsafe {
+ let pgid = ret_pid_t(c::getpgid(Pid::as_raw(pid) as _))?;
+ debug_assert_ne!(pgid, 0);
+ Ok(Pid::from_raw_nonzero(RawNonZeroPid::new_unchecked(pgid)))
+ }
+}
+
+#[cfg(not(target_os = "wasi"))]
+#[inline]
+#[must_use]
+pub(crate) fn getpgrp() -> Pid {
+ unsafe {
+ let pgid = c::getpgrp();
+ debug_assert_ne!(pgid, 0);
+ Pid::from_raw_nonzero(RawNonZeroPid::new_unchecked(pgid))
+ }
+}
+
+#[cfg(any(
+ target_os = "android",
+ target_os = "dragonfly",
+ target_os = "fuchsia",
+ target_os = "linux",
+))]
+#[inline]
+pub(crate) fn sched_getaffinity(pid: Option<Pid>, cpuset: &mut RawCpuSet) -> io::Result<()> {
+ unsafe {
+ ret(c::sched_getaffinity(
+ Pid::as_raw(pid) as _,
+ core::mem::size_of::<RawCpuSet>(),
+ cpuset,
+ ))
+ }
+}
+
+#[cfg(any(
+ target_os = "android",
+ target_os = "dragonfly",
+ target_os = "fuchsia",
+ target_os = "linux",
+))]
+#[inline]
+pub(crate) fn sched_setaffinity(pid: Option<Pid>, cpuset: &RawCpuSet) -> io::Result<()> {
+ unsafe {
+ ret(c::sched_setaffinity(
+ Pid::as_raw(pid) as _,
+ core::mem::size_of::<RawCpuSet>(),
+ cpuset,
+ ))
+ }
+}
+
+#[inline]
+pub(crate) fn sched_yield() {
+ unsafe {
+ let _ = c::sched_yield();
+ }
+}
+
+#[cfg(not(target_os = "wasi"))]
+#[inline]
+pub(crate) fn uname() -> RawUname {
+ let mut uname = MaybeUninit::<RawUname>::uninit();
+ unsafe {
+ ret(c::uname(uname.as_mut_ptr())).unwrap();
+ uname.assume_init()
+ }
+}
+
+#[cfg(not(any(target_os = "fuchsia", target_os = "wasi")))]
+#[inline]
+pub(crate) fn nice(inc: i32) -> io::Result<i32> {
+ libc_errno::set_errno(libc_errno::Errno(0));
+ let r = unsafe { c::nice(inc) };
+ if libc_errno::errno().0 != 0 {
+ ret_c_int(r)
+ } else {
+ Ok(r)
+ }
+}
+
+#[cfg(not(any(target_os = "fuchsia", target_os = "redox", target_os = "wasi")))]
+#[inline]
+pub(crate) fn getpriority_user(uid: Uid) -> io::Result<i32> {
+ libc_errno::set_errno(libc_errno::Errno(0));
+ let r = unsafe { c::getpriority(c::PRIO_USER, uid.as_raw() as _) };
+ if libc_errno::errno().0 != 0 {
+ ret_c_int(r)
+ } else {
+ Ok(r)
+ }
+}
+
+#[cfg(not(any(target_os = "fuchsia", target_os = "redox", target_os = "wasi")))]
+#[inline]
+pub(crate) fn getpriority_pgrp(pgid: Option<Pid>) -> io::Result<i32> {
+ libc_errno::set_errno(libc_errno::Errno(0));
+ let r = unsafe { c::getpriority(c::PRIO_PGRP, Pid::as_raw(pgid) as _) };
+ if libc_errno::errno().0 != 0 {
+ ret_c_int(r)
+ } else {
+ Ok(r)
+ }
+}
+
+#[cfg(not(any(target_os = "fuchsia", target_os = "redox", target_os = "wasi")))]
+#[inline]
+pub(crate) fn getpriority_process(pid: Option<Pid>) -> io::Result<i32> {
+ libc_errno::set_errno(libc_errno::Errno(0));
+ let r = unsafe { c::getpriority(c::PRIO_PROCESS, Pid::as_raw(pid) as _) };
+ if libc_errno::errno().0 != 0 {
+ ret_c_int(r)
+ } else {
+ Ok(r)
+ }
+}
+
+#[cfg(not(any(target_os = "fuchsia", target_os = "redox", target_os = "wasi")))]
+#[inline]
+pub(crate) fn setpriority_user(uid: Uid, priority: i32) -> io::Result<()> {
+ unsafe { ret(c::setpriority(c::PRIO_USER, uid.as_raw() as _, priority)) }
+}
+
+#[cfg(not(any(target_os = "fuchsia", target_os = "redox", target_os = "wasi")))]
+#[inline]
+pub(crate) fn setpriority_pgrp(pgid: Option<Pid>, priority: i32) -> io::Result<()> {
+ unsafe {
+ ret(c::setpriority(
+ c::PRIO_PGRP,
+ Pid::as_raw(pgid) as _,
+ priority,
+ ))
+ }
+}
+
+#[cfg(not(any(target_os = "fuchsia", target_os = "redox", target_os = "wasi")))]
+#[inline]
+pub(crate) fn setpriority_process(pid: Option<Pid>, priority: i32) -> io::Result<()> {
+ unsafe {
+ ret(c::setpriority(
+ c::PRIO_PROCESS,
+ Pid::as_raw(pid) as _,
+ priority,
+ ))
+ }
+}
+
+#[cfg(not(any(target_os = "fuchsia", target_os = "redox", target_os = "wasi")))]
+#[inline]
+pub(crate) fn getrlimit(limit: Resource) -> Rlimit {
+ let mut result = MaybeUninit::<libc_rlimit>::uninit();
+ unsafe {
+ ret_infallible(libc_getrlimit(limit as _, result.as_mut_ptr()));
+ rlimit_from_libc(result.assume_init())
+ }
+}
+
+#[cfg(not(any(target_os = "fuchsia", target_os = "redox", target_os = "wasi")))]
+#[inline]
+pub(crate) fn setrlimit(limit: Resource, new: Rlimit) -> io::Result<()> {
+ let lim = rlimit_to_libc(new)?;
+ unsafe { ret(libc_setrlimit(limit as _, &lim)) }
+}
+
+#[cfg(any(target_os = "android", target_os = "linux"))]
+#[inline]
+pub(crate) fn prlimit(pid: Option<Pid>, limit: Resource, new: Rlimit) -> io::Result<Rlimit> {
+ let lim = rlimit_to_libc(new)?;
+ let mut result = MaybeUninit::<libc_rlimit>::uninit();
+ unsafe {
+ ret(libc_prlimit(
+ Pid::as_raw(pid),
+ limit as _,
+ &lim,
+ result.as_mut_ptr(),
+ ))?;
+ Ok(rlimit_from_libc(result.assume_init()))
+ }
+}
+
+/// Convert a Rust [`Rlimit`] to a C `libc_rlimit`.
+#[cfg(not(any(target_os = "fuchsia", target_os = "redox", target_os = "wasi")))]
+fn rlimit_from_libc(lim: libc_rlimit) -> Rlimit {
+ let current = if lim.rlim_cur == LIBC_RLIM_INFINITY {
+ None
+ } else {
+ Some(lim.rlim_cur.try_into().unwrap())
+ };
+ let maximum = if lim.rlim_max == LIBC_RLIM_INFINITY {
+ None
+ } else {
+ Some(lim.rlim_max.try_into().unwrap())
+ };
+ Rlimit { current, maximum }
+}
+
+/// Convert a C `libc_rlimit` to a Rust `Rlimit`.
+#[cfg(not(any(target_os = "fuchsia", target_os = "redox", target_os = "wasi")))]
+fn rlimit_to_libc(lim: Rlimit) -> io::Result<libc_rlimit> {
+ let Rlimit { current, maximum } = lim;
+ let rlim_cur = match current {
+ Some(r) => r.try_into().map_err(|_e| io::Errno::INVAL)?,
+ None => LIBC_RLIM_INFINITY as _,
+ };
+ let rlim_max = match maximum {
+ Some(r) => r.try_into().map_err(|_e| io::Errno::INVAL)?,
+ None => LIBC_RLIM_INFINITY as _,
+ };
+ Ok(libc_rlimit { rlim_cur, rlim_max })
+}
+
+#[cfg(not(target_os = "wasi"))]
+#[inline]
+pub(crate) fn wait(waitopts: WaitOptions) -> io::Result<Option<(Pid, WaitStatus)>> {
+ _waitpid(!0, waitopts)
+}
+
+#[cfg(not(target_os = "wasi"))]
+#[inline]
+pub(crate) fn waitpid(
+ pid: Option<Pid>,
+ waitopts: WaitOptions,
+) -> io::Result<Option<(Pid, WaitStatus)>> {
+ _waitpid(Pid::as_raw(pid), waitopts)
+}
+
+#[cfg(not(target_os = "wasi"))]
+#[inline]
+pub(crate) fn _waitpid(
+ pid: RawPid,
+ waitopts: WaitOptions,
+) -> io::Result<Option<(Pid, WaitStatus)>> {
+ unsafe {
+ let mut status: c::c_int = 0;
+ let pid = ret_c_int(c::waitpid(pid as _, &mut status, waitopts.bits() as _))?;
+ Ok(RawNonZeroPid::new(pid).map(|non_zero| {
+ (
+ Pid::from_raw_nonzero(non_zero),
+ WaitStatus::new(status as _),
+ )
+ }))
+ }
+}
+
+#[inline]
+pub(crate) fn exit_group(code: c::c_int) -> ! {
+ // `_exit` and `_Exit` are the same; it's just a matter of which ones
+ // the libc bindings expose.
+ #[cfg(any(target_os = "wasi", target_os = "solid"))]
+ unsafe {
+ c::_Exit(code)
+ }
+ #[cfg(unix)]
+ unsafe {
+ c::_exit(code)
+ }
+}
+
+#[cfg(not(target_os = "wasi"))]
+#[inline]
+pub(crate) fn setsid() -> io::Result<Pid> {
+ unsafe {
+ let pid = ret_c_int(c::setsid())?;
+ debug_assert_ne!(pid, 0);
+ Ok(Pid::from_raw_nonzero(RawNonZeroPid::new_unchecked(pid)))
+ }
+}
+
+#[cfg(not(target_os = "wasi"))]
+#[inline]
+pub(crate) fn kill_process(pid: Pid, sig: Signal) -> io::Result<()> {
+ unsafe { ret(c::kill(pid.as_raw_nonzero().get(), sig as i32)) }
+}
+
+#[cfg(not(target_os = "wasi"))]
+#[inline]
+pub(crate) fn kill_process_group(pid: Pid, sig: Signal) -> io::Result<()> {
+ unsafe {
+ ret(c::kill(
+ pid.as_raw_nonzero().get().wrapping_neg(),
+ sig as i32,
+ ))
+ }
+}
+
+#[cfg(not(target_os = "wasi"))]
+#[inline]
+pub(crate) fn kill_current_process_group(sig: Signal) -> io::Result<()> {
+ unsafe { ret(c::kill(0, sig as i32)) }
+}
+
+#[cfg(any(target_os = "android", target_os = "linux"))]
+#[inline]
+pub(crate) unsafe fn prctl(
+ option: c::c_int,
+ arg2: *mut c::c_void,
+ arg3: *mut c::c_void,
+ arg4: *mut c::c_void,
+ arg5: *mut c::c_void,
+) -> io::Result<c::c_int> {
+ ret_c_int(c::prctl(option, arg2, arg3, arg4, arg5))
+}
+
+#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
+#[inline]
+pub(crate) unsafe fn procctl(
+ idtype: c::idtype_t,
+ id: c::id_t,
+ option: c::c_int,
+ data: *mut c::c_void,
+) -> io::Result<()> {
+ ret(c::procctl(idtype, id, option, data))
+}
diff --git a/vendor/rustix/src/backend/libc/process/types.rs b/vendor/rustix/src/backend/libc/process/types.rs
new file mode 100644
index 000000000..f8e3b8bf4
--- /dev/null
+++ b/vendor/rustix/src/backend/libc/process/types.rs
@@ -0,0 +1,414 @@
+use super::super::c;
+
+/// A command for use with [`membarrier`] and [`membarrier_cpu`].
+///
+/// For `MEMBARRIER_CMD_QUERY`, see [`membarrier_query`].
+///
+/// [`membarrier`]: crate::process::membarrier
+/// [`membarrier_cpu`]: crate::process::membarrier_cpu
+/// [`membarrier_query`]: crate::process::membarrier_query
+// TODO: These are not yet exposed through libc, so we define the
+// constants ourselves.
+#[cfg(any(target_os = "android", target_os = "linux"))]
+#[derive(Copy, Clone, Eq, PartialEq, Debug)]
+#[repr(u32)]
+pub enum MembarrierCommand {
+ /// `MEMBARRIER_CMD_GLOBAL`
+ #[doc(alias = "Shared")]
+ #[doc(alias = "MEMBARRIER_CMD_SHARED")]
+ Global = 1,
+ /// `MEMBARRIER_CMD_GLOBAL_EXPEDITED`
+ GlobalExpedited = 2,
+ /// `MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED`
+ RegisterGlobalExpedited = 4,
+ /// `MEMBARRIER_CMD_PRIVATE_EXPEDITED`
+ PrivateExpedited = 8,
+ /// `MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED`
+ RegisterPrivateExpedited = 16,
+ /// `MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE`
+ PrivateExpeditedSyncCore = 32,
+ /// `MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE`
+ RegisterPrivateExpeditedSyncCore = 64,
+ /// `MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ` (since Linux 5.10)
+ PrivateExpeditedRseq = 128,
+ /// `MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ` (since Linux 5.10)
+ RegisterPrivateExpeditedRseq = 256,
+}
+
+/// A resource value for use with [`getrlimit`], [`setrlimit`], and
+/// [`prlimit`].
+///
+/// [`getrlimit`]: crate::process::getrlimit
+/// [`setrlimit`]: crate::process::setrlimit
+/// [`prlimit`]: crate::process::prlimit
+#[cfg(not(any(target_os = "fuchsia", target_os = "redox", target_os = "wasi")))]
+#[derive(Copy, Clone, Debug, Eq, PartialEq)]
+#[repr(i32)]
+pub enum Resource {
+ /// `RLIMIT_CPU`
+ Cpu = c::RLIMIT_CPU as c::c_int,
+ /// `RLIMIT_FSIZE`
+ Fsize = c::RLIMIT_FSIZE as c::c_int,
+ /// `RLIMIT_DATA`
+ Data = c::RLIMIT_DATA as c::c_int,
+ /// `RLIMIT_STACK`
+ Stack = c::RLIMIT_STACK as c::c_int,
+ /// `RLIMIT_CORE`
+ #[cfg(not(target_os = "haiku"))]
+ Core = c::RLIMIT_CORE as c::c_int,
+ /// `RLIMIT_RSS`
+ #[cfg(not(any(
+ target_os = "haiku",
+ target_os = "illumos",
+ target_os = "ios",
+ target_os = "macos",
+ target_os = "solaris",
+ )))]
+ Rss = c::RLIMIT_RSS as c::c_int,
+ /// `RLIMIT_NPROC`
+ #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
+ Nproc = c::RLIMIT_NPROC as c::c_int,
+ /// `RLIMIT_NOFILE`
+ Nofile = c::RLIMIT_NOFILE as c::c_int,
+ /// `RLIMIT_MEMLOCK`
+ #[cfg(not(any(
+ target_os = "aix",
+ target_os = "haiku",
+ target_os = "illumos",
+ target_os = "solaris"
+ )))]
+ Memlock = c::RLIMIT_MEMLOCK as c::c_int,
+ /// `RLIMIT_AS`
+ #[cfg(not(target_os = "openbsd"))]
+ As = c::RLIMIT_AS as c::c_int,
+ /// `RLIMIT_LOCKS`
+ #[cfg(not(any(
+ target_os = "aix",
+ target_os = "dragonfly",
+ target_os = "freebsd",
+ target_os = "haiku",
+ target_os = "illumos",
+ target_os = "ios",
+ target_os = "macos",
+ target_os = "netbsd",
+ target_os = "openbsd",
+ target_os = "solaris",
+ )))]
+ Locks = c::RLIMIT_LOCKS as c::c_int,
+ /// `RLIMIT_SIGPENDING`
+ #[cfg(not(any(
+ target_os = "aix",
+ target_os = "dragonfly",
+ target_os = "freebsd",
+ target_os = "haiku",
+ target_os = "illumos",
+ target_os = "ios",
+ target_os = "macos",
+ target_os = "netbsd",
+ target_os = "openbsd",
+ target_os = "solaris",
+ )))]
+ Sigpending = c::RLIMIT_SIGPENDING as c::c_int,
+ /// `RLIMIT_MSGQUEUE`
+ #[cfg(not(any(
+ target_os = "aix",
+ target_os = "dragonfly",
+ target_os = "freebsd",
+ target_os = "haiku",
+ target_os = "illumos",
+ target_os = "ios",
+ target_os = "macos",
+ target_os = "netbsd",
+ target_os = "openbsd",
+ target_os = "solaris",
+ )))]
+ Msgqueue = c::RLIMIT_MSGQUEUE as c::c_int,
+ /// `RLIMIT_NICE`
+ #[cfg(not(any(
+ target_os = "aix",
+ target_os = "dragonfly",
+ target_os = "freebsd",
+ target_os = "haiku",
+ target_os = "illumos",
+ target_os = "ios",
+ target_os = "macos",
+ target_os = "netbsd",
+ target_os = "openbsd",
+ target_os = "solaris",
+ )))]
+ Nice = c::RLIMIT_NICE as c::c_int,
+ /// `RLIMIT_RTPRIO`
+ #[cfg(not(any(
+ target_os = "aix",
+ target_os = "dragonfly",
+ target_os = "freebsd",
+ target_os = "haiku",
+ target_os = "illumos",
+ target_os = "ios",
+ target_os = "macos",
+ target_os = "netbsd",
+ target_os = "openbsd",
+ target_os = "solaris",
+ )))]
+ Rtprio = c::RLIMIT_RTPRIO as c::c_int,
+ /// `RLIMIT_RTTIME`
+ #[cfg(not(any(
+ target_os = "aix",
+ target_os = "android",
+ target_os = "dragonfly",
+ target_os = "emscripten",
+ target_os = "freebsd",
+ target_os = "haiku",
+ target_os = "illumos",
+ target_os = "ios",
+ target_os = "macos",
+ target_os = "netbsd",
+ target_os = "openbsd",
+ target_os = "solaris",
+ )))]
+ Rttime = c::RLIMIT_RTTIME as c::c_int,
+}
+
+#[cfg(any(target_os = "ios", target_os = "macos"))]
+impl Resource {
+ /// `RLIMIT_RSS`
+ #[allow(non_upper_case_globals)]
+ pub const Rss: Self = Self::As;
+}
+
+/// A signal number for use with [`kill_process`], [`kill_process_group`],
+/// and [`kill_current_process_group`].
+///
+/// [`kill_process`]: crate::process::kill_process
+/// [`kill_process_group`]: crate::process::kill_process_group
+/// [`kill_current_process_group`]: crate::process::kill_current_process_group
+#[cfg(not(target_os = "wasi"))]
+#[derive(Copy, Clone, Debug, Eq, PartialEq)]
+#[repr(i32)]
+pub enum Signal {
+ /// `SIGHUP`
+ Hup = c::SIGHUP,
+ /// `SIGINT`
+ Int = c::SIGINT,
+ /// `SIGQUIT`
+ Quit = c::SIGQUIT,
+ /// `SIGILL`
+ Ill = c::SIGILL,
+ /// `SIGTRAP`
+ Trap = c::SIGTRAP,
+ /// `SIGABRT`, aka `SIGIOT`
+ #[doc(alias = "Iot")]
+ #[doc(alias = "Abrt")]
+ Abort = c::SIGABRT,
+ /// `SIGBUS`
+ Bus = c::SIGBUS,
+ /// `SIGFPE`
+ Fpe = c::SIGFPE,
+ /// `SIGKILL`
+ Kill = c::SIGKILL,
+ /// `SIGUSR1`
+ Usr1 = c::SIGUSR1,
+ /// `SIGSEGV`
+ Segv = c::SIGSEGV,
+ /// `SIGUSR2`
+ Usr2 = c::SIGUSR2,
+ /// `SIGPIPE`
+ Pipe = c::SIGPIPE,
+ /// `SIGALRM`
+ #[doc(alias = "Alrm")]
+ Alarm = c::SIGALRM,
+ /// `SIGTERM`
+ Term = c::SIGTERM,
+ /// `SIGSTKFLT`
+ #[cfg(not(any(
+ target_os = "aix",
+ target_os = "dragonfly",
+ target_os = "freebsd",
+ target_os = "haiku",
+ target_os = "illumos",
+ target_os = "ios",
+ target_os = "macos",
+ target_os = "netbsd",
+ target_os = "openbsd",
+ target_os = "solaris",
+ all(
+ any(target_os = "android", target_os = "linux"),
+ any(
+ target_arch = "mips",
+ target_arch = "mips64",
+ target_arch = "sparc",
+ target_arch = "sparc64"
+ ),
+ )
+ )))]
+ Stkflt = c::SIGSTKFLT,
+ /// `SIGCHLD`
+ #[doc(alias = "Chld")]
+ Child = c::SIGCHLD,
+ /// `SIGCONT`
+ Cont = c::SIGCONT,
+ /// `SIGSTOP`
+ Stop = c::SIGSTOP,
+ /// `SIGTSTP`
+ Tstp = c::SIGTSTP,
+ /// `SIGTTIN`
+ Ttin = c::SIGTTIN,
+ /// `SIGTTOU`
+ Ttou = c::SIGTTOU,
+ /// `SIGURG`
+ Urg = c::SIGURG,
+ /// `SIGXCPU`
+ Xcpu = c::SIGXCPU,
+ /// `SIGXFSZ`
+ Xfsz = c::SIGXFSZ,
+ /// `SIGVTALRM`
+ #[doc(alias = "Vtalrm")]
+ Vtalarm = c::SIGVTALRM,
+ /// `SIGPROF`
+ Prof = c::SIGPROF,
+ /// `SIGWINCH`
+ Winch = c::SIGWINCH,
+ /// `SIGIO`, aka `SIGPOLL`
+ #[doc(alias = "Poll")]
+ #[cfg(not(target_os = "haiku"))]
+ Io = c::SIGIO,
+ /// `SIGPWR`
+ #[cfg(not(any(
+ target_os = "dragonfly",
+ target_os = "freebsd",
+ target_os = "haiku",
+ target_os = "ios",
+ target_os = "macos",
+ target_os = "netbsd",
+ target_os = "openbsd",
+ )))]
+ #[doc(alias = "Pwr")]
+ Power = c::SIGPWR,
+ /// `SIGSYS`, aka `SIGUNUSED`
+ #[doc(alias = "Unused")]
+ Sys = c::SIGSYS,
+}
+
+#[cfg(not(target_os = "wasi"))]
+impl Signal {
+ /// Convert a raw signal number into a `Signal`, if possible.
+ pub fn from_raw(sig: i32) -> Option<Self> {
+ match sig as _ {
+ c::SIGHUP => Some(Self::Hup),
+ c::SIGINT => Some(Self::Int),
+ c::SIGQUIT => Some(Self::Quit),
+ c::SIGILL => Some(Self::Ill),
+ c::SIGTRAP => Some(Self::Trap),
+ c::SIGABRT => Some(Self::Abort),
+ c::SIGBUS => Some(Self::Bus),
+ c::SIGFPE => Some(Self::Fpe),
+ c::SIGKILL => Some(Self::Kill),
+ c::SIGUSR1 => Some(Self::Usr1),
+ c::SIGSEGV => Some(Self::Segv),
+ c::SIGUSR2 => Some(Self::Usr2),
+ c::SIGPIPE => Some(Self::Pipe),
+ c::SIGALRM => Some(Self::Alarm),
+ c::SIGTERM => Some(Self::Term),
+ #[cfg(not(any(
+ target_os = "aix",
+ target_os = "dragonfly",
+ target_os = "freebsd",
+ target_os = "haiku",
+ target_os = "illumos",
+ target_os = "ios",
+ target_os = "macos",
+ target_os = "netbsd",
+ target_os = "openbsd",
+ target_os = "solaris",
+ all(
+ any(target_os = "android", target_os = "linux"),
+ any(
+ target_arch = "mips",
+ target_arch = "mips64",
+ target_arch = "sparc",
+ target_arch = "sparc64"
+ ),
+ )
+ )))]
+ c::SIGSTKFLT => Some(Self::Stkflt),
+ c::SIGCHLD => Some(Self::Child),
+ c::SIGCONT => Some(Self::Cont),
+ c::SIGSTOP => Some(Self::Stop),
+ c::SIGTSTP => Some(Self::Tstp),
+ c::SIGTTIN => Some(Self::Ttin),
+ c::SIGTTOU => Some(Self::Ttou),
+ c::SIGURG => Some(Self::Urg),
+ c::SIGXCPU => Some(Self::Xcpu),
+ c::SIGXFSZ => Some(Self::Xfsz),
+ c::SIGVTALRM => Some(Self::Vtalarm),
+ c::SIGPROF => Some(Self::Prof),
+ c::SIGWINCH => Some(Self::Winch),
+ #[cfg(not(target_os = "haiku"))]
+ c::SIGIO => Some(Self::Io),
+ #[cfg(not(any(
+ target_os = "dragonfly",
+ target_os = "freebsd",
+ target_os = "haiku",
+ target_os = "ios",
+ target_os = "macos",
+ target_os = "netbsd",
+ target_os = "openbsd",
+ )))]
+ c::SIGPWR => Some(Self::Power),
+ c::SIGSYS => Some(Self::Sys),
+ _ => None,
+ }
+ }
+}
+
+pub const EXIT_SUCCESS: c::c_int = c::EXIT_SUCCESS;
+pub const EXIT_FAILURE: c::c_int = c::EXIT_FAILURE;
+#[cfg(not(target_os = "wasi"))]
+pub const EXIT_SIGNALED_SIGABRT: c::c_int = 128 + c::SIGABRT;
+
+/// A process identifier as a raw integer.
+#[cfg(not(target_os = "wasi"))]
+pub type RawPid = c::pid_t;
+/// A non-zero process identifier as a raw non-zero integer.
+#[cfg(not(target_os = "wasi"))]
+pub type RawNonZeroPid = core::num::NonZeroI32;
+/// A group identifier as a raw integer.
+#[cfg(not(target_os = "wasi"))]
+pub type RawGid = c::gid_t;
+/// A user identifier as a raw integer.
+#[cfg(not(target_os = "wasi"))]
+pub type RawUid = c::uid_t;
+/// A CPU identifier as a raw integer.
+#[cfg(any(target_os = "android", target_os = "linux"))]
+pub type RawCpuid = u32;
+#[cfg(target_os = "freebsd")]
+pub type RawId = c::id_t;
+
+#[cfg(not(target_os = "wasi"))]
+pub(crate) type RawUname = c::utsname;
+
+#[cfg(any(
+ target_os = "android",
+ target_os = "dragonfly",
+ target_os = "fuchsia",
+ target_os = "linux",
+))]
+pub(crate) type RawCpuSet = c::cpu_set_t;
+
+#[cfg(any(
+ target_os = "android",
+ target_os = "dragonfly",
+ target_os = "fuchsia",
+ target_os = "linux",
+))]
+#[inline]
+pub(crate) fn raw_cpu_set_new() -> RawCpuSet {
+ let mut set = unsafe { core::mem::zeroed() };
+ super::cpu_set::CPU_ZERO(&mut set);
+ set
+}
+
+#[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))]
+pub(crate) const CPU_SETSIZE: usize = c::CPU_SETSIZE as usize;
+#[cfg(target_os = "dragonfly")]
+pub(crate) const CPU_SETSIZE: usize = 256;
diff --git a/vendor/rustix/src/backend/libc/process/wait.rs b/vendor/rustix/src/backend/libc/process/wait.rs
new file mode 100644
index 000000000..6de79955d
--- /dev/null
+++ b/vendor/rustix/src/backend/libc/process/wait.rs
@@ -0,0 +1,6 @@
+use super::super::c;
+
+pub(crate) use c::{
+ WCONTINUED, WEXITSTATUS, WIFCONTINUED, WIFEXITED, WIFSIGNALED, WIFSTOPPED, WNOHANG, WSTOPSIG,
+ WTERMSIG, WUNTRACED,
+};