about summary refs log tree commit diff
path: root/library/std/src/os/unix/process.rs
AgeCommit message (Collapse)AuthorLines
2025-09-19Fix test suite in iOS/tvOS/watchOS/visionOS simulatorMads Marquart-0/+2
2025-08-16library: Migrate from `cfg_if` to `cfg_select`Josh Triplett-6/+6
Migrate the standard library from using the external `cfg_if` crate to using the now-built-in `cfg_select` macro. This does not yet eliminate the dependency from `library/std/Cargo.toml`, because while the standard library itself no longer uses `cfg_if`, it also incorporates the `backtrace` crate, which does. Migration assisted by the following vim command (after selecting the full `cfg_if!` invocation): ``` '<,'>s/\(cfg_if::\)\?cfg_if/cfg_select/ | '<,'>s/^\( *\)} else {/\1}\r\1_ => {/c | '<,'>s/^\( *\)} else if #\[cfg(\(.*\))\] /\1}\r\1\2 => /e | '<,'>s/if #\[cfg(\(.*\))\] {/\1 => {/e ``` This is imperfect, but substantially accelerated the process. This prompts for confirmation on the `} else {` since that can also appear inside one of the arms. This also requires manual intervention to handle any multi-line conditions.
2025-07-11Rollup merge of #142391 - LevitatingBusinessMan:setsid, r=workingjubileeMatthias Krüger-0/+8
rust: library: Add `setsid` method to `CommandExt` trait Add a setsid method to the CommandExt trait so that callers can create a process in a new session and process group whilst still using the POSIX spawn fast path. Tracking issue: rust-lang/rust#105376 ACP: https://github.com/rust-lang/libs-team/issues/184 This PR was previously submitted by ``@HarveyHunt`` (whom I marked as Co-Author in the commit message) in rust-lang/rust#105377. However that PR went stale. I applied the [suggestion](https://github.com/rust-lang/rust/pull/105377/files/231d19fcbfe155b2e85116865adae4253380ff1f#r1893457943) to change the function signature to `fn setsid(&mut self, setsid: bool) -> &mut Command`.
2025-07-10rust: library: Add setsid method to CommandExt traitLevitatingBusinessMan (Rein Fernhout)-0/+8
Add a setsid method to the CommandExt trait so that callers can create a process in a new session and process group whilst still using the POSIX spawn fast path. Co-Authored-By: Harvey Hunt <harveyhunt@fb.com>
2025-07-03setup CI and tidy to use typos for spellchecking and fix few typosklensy-1/+1
2025-06-18add ChildExt(::send_signal)Jeremy Smart-0/+35
2025-05-21Apply suggestions from code reviewJosh Triplett-5/+5
Link `Command::current_dir`. Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
2025-05-20`CommandExt::chroot`: Add tracking issueJosh Triplett-1/+1
2025-05-20`CommandExt::chroot`: Document difference to underlying `chroot`Josh Triplett-3/+5
2025-05-20Add `std::os::unix::process::CommandExt::chroot` to safely chroot a child ↵Josh Triplett-0/+16
process This adds a `chroot` method to the `CommandExt` extension trait for the `Command` builder, to set a directory to chroot into. This will chroot the child process into that directory right before calling chdir for the `Command`'s working directory. To avoid allowing a process to have a working directory outside of the chroot, if the `Command` does not yet have a working directory set, `chroot` will set its working directory to "/".
2024-11-04docs: fix grammar in doc comment at unix/process.rsNotWearingPants-1/+1
2024-10-17Add must_use to CommandExt::execCallum Ryan-0/+1
2024-09-05update cfgsBoxy-5/+1
2024-08-14CommandExt::before_exec: deprecate safety in edition 2024Ralf Jung-3/+11
2024-07-29Reformat `use` declarations.Nicholas Nethercote-5/+3
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-26Fix doc nitsJohn Arundel-3/+3
Many tiny changes to stdlib doc comments to make them consistent (for example "Returns foo", rather than "Return foo", per RFC1574), adding missing periods, paragraph breaks, backticks for monospace style, and other minor nits. https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md#appendix-a-full-conventions-text
2024-02-26change std::process to drop supplementary groups based on CAP_SETGIDElliot Roberts-0/+7
2024-02-04Document various I/O handle conversionsRyan Lowe-0/+5
2023-10-03Bump version placeholdersMark Rousskov-3/+3
2023-09-28Auto merge of #98704 - vthib:impl-from-raw-for-childstd-structs, r=dtolnaybors-0/+42
Implement From<OwnedFd/Handle> for ChildStdin/out/err object ## Summary Comments in `library/std/src/process.rs` ( https://github.com/rust-lang/rust/commit/ab08639e5950f5c8a42a2870c9636181308c3686 ) indicates that `ChildStdin`, `ChildStdout`, `ChildStderr` implements some traits that are not actually implemented: `FromRawFd`, `FromRawHandle`, and the `From<OwnedFd>/From<OwnedHandle>` from the io_safety feature. In this PR I implement `FromRawHandle` and `FromRawFd` for those 3 objects. ## Usecase I have a usecase where those implementations are basically needed. I want to customize in the `Command::spawn` API how the pipes for the parent/child communications are created (mainly to strengthen the security attributes on them). I can properly setup the pipes, and the "child" handles can be provided to `Child::spawn` easily using `Stdio::from_raw_handle`. However, there is no way to generate the `ChildStd*` objects from the raw handle of the created name pipe, which would be very useful to still expose the same API than in other OS (basically a `spawn(...) -> (Child, ChildStdin, ChildStdout, ChildSterr)`, where on windows this is customized), and to for example use `tokio::ChildStdin::from_std` afterwards. ## Questions * Are those impls OK to add? I have searched to see if those impls were missing on purpose, or if it was just never implemented because never needed. I haven't found any indication on why they couldn't be added, although the user clearly has to be very careful that the handle provided makes sense (i think, mainly that it is in overlapped mode for windows). * If this change is ok, adding the impls for the io_safety feature would probably be best, or should it be done in another PR? * I just copy-pasted the `#[stable(...)]` attributes, but the `since` value has to be updated, I'm not sure to which value.
2023-09-28Update stability attribute for child stream From implsDavid Tolnay-3/+3
2023-06-05Std support improvement for ps vita targetNikolay Arhipov-1/+1
2023-05-30add doc on From<OwnedFd/Handle> impl for ChildStd*Vincent Thiberville-0/+12
2023-05-30add FromOwnedFd/FromOwnedHandle for ChildStdin/out/errVincent Thiberville-0/+30
2023-02-28Add QNX Neutrino support to libstdFlorian Bartels-9/+17
Co-authored-by: gh-tr <troach@qnx.com>
2022-07-16Expand documentation for `process_group` Josh Triplett-1/+3
Explain PGID 0, and provide the acronym PGID.
2022-07-09Document and stabilize process_set_process_groupNiklas Fiekas-3/+28
Tracking issue: https://github.com/rust-lang/rust/issues/93857 FCP finished here: https://github.com/rust-lang/rust/issues/93857#issuecomment-1179551697
2022-06-15Auto merge of #95897 - AzureMarker:feature/horizon-std, r=nagisabors-30/+16
STD support for the Nintendo 3DS Rustc already supports compiling for the Nintendo 3DS using the `armv6k-nintendo-3ds` target (Tier 3). Until now though, only `core` and `alloc` were supported. This PR adds standard library support for the Nintendo 3DS. A notable exclusion is `std::thread` support, which will come in a follow-up PR as it requires more complicated changes. This has been a joint effort by `@Meziu,` `@ian-h-chamberlain,` myself, and prior work by `@rust3ds` members. ### Background The Nintendo 3DS (Horizon OS) is a mostly-UNIX looking system, with the caveat that it does not come with a full libc implementation out of the box. On the homebrew side (I'm not under NDA), the libc interface is partially implemented by the [devkitPro](https://devkitpro.org/wiki/devkitPro_pacman) toolchain and a user library like [`libctru`](https://github.com/devkitPro/libctru). This is important because there are [some possible legal barriers](https://github.com/rust-lang/rust/pull/88529#issuecomment-919938396) to linking directly to a library that uses the underlying platform APIs, since they might be considered a trade secret or under NDA. To get around this, the standard library impl for the 3DS does not directly depend on any platform-level APIs. Instead, it expects standard libc functions to be linked in. The implementation of these libc functions is left to the user. Some functions are provided by the devkitPro toolchain, but in our testing, we used the following to fill in the other functions: - [`libctru`] - provides more basic APIs, such as `nanosleep`. Linked in by way of [`ctru-sys`](https://github.com/Meziu/ctru-rs/tree/master/ctru-sys). - [`pthread-3ds`](https://github.com/Meziu/pthread-3ds) - provides pthread APIs for `std::thread`. Implemented using [`libctru`]. - [`linker-fix-3ds`](https://github.com/Meziu/rust-linker-fix-3ds) - fulfills some other missing libc APIs. Implemented using [`libctru`]. For more details, see the `src/doc/rustc/src/platform-support/armv6k-nintendo-3ds.md` file added in this PR. ### Notes We've already upstreamed changes to the [`libc`] crate to support this PR, as well as the upcoming threading PR. These changes have all been released as of 0.2.121, so we bump the crate version in this PR. Edit: After some rebases, the version bump has already been merged so it doesn't appear in this PR. A lot of the changes in this PR are straightforward, and follow in the footsteps of the ESP-IDF target: https://github.com/rust-lang/rust/pull/87666. The 3DS does not support user space process spawning, so these APIs are unimplemented (similar to ESP-IDF). [`libctru`]: https://github.com/devkitPro/libctru [`libc`]: https://github.com/rust-lang/libc
2022-06-14Implement stabilization of `#[feature(io_safety)]`.Dan Gohman-7/+7
Implement stabilization of [I/O safety], aka `#[feature(io_safety)]`. Fixes #87074. [I/O safety]: https://github.com/rust-lang/rfcs/blob/master/text/3128-io-safety.md
2022-06-13Use a private type definition to reduce cfg noiseMark Drobnak-36/+16
I checked with t-libs to make sure this is OK to do on stable functions: https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Replacing.20std.20function.20arg.20type.20with.20private.20type.20def.3F
2022-06-13Horizon OS STD supportMeziu-12/+18
Co-authored-by: Ian Chamberlain <ian.h.chamberlain@gmail.com> Co-authored-by: Mark Drobnak <mark.drobnak@gmail.com>
2022-05-09Auto merge of #95960 - jhpratt:remove-rustc_deprecated, r=compiler-errorsbors-1/+1
Remove `#[rustc_deprecated]` This removes `#[rustc_deprecated]` and introduces diagnostics to help users to the right direction (that being `#[deprecated]`). All uses of `#[rustc_deprecated]` have been converted. CI is expected to fail initially; this requires #95958, which includes converting `stdarch`. I plan on following up in a short while (maybe a bootstrap cycle?) removing the diagnostics, as they're only intended to be short-term.
2022-04-19espidf: fix statScott Mabin-12/+12
* corect type usage with new type definitions in libc
2022-04-14Remove use of `#[rustc_deprecated]`Jacob Pratt-1/+1
2022-03-14Add a `process_group` method to UNIX `CommandExt`Thomas Orozco-0/+10
2021-11-12Rollup merge of #90704 - ijackson:exitstatus-comments, r=joshtriplettMatthias Krüger-1/+1
Unix ExitStatus comments and a tiny docs fix Some nits left over from #88300
2021-11-11unix::ExitStatusExt: Correct reference to _exit system callIan Jackson-1/+1
As discussed here https://github.com/rust-lang/rust/pull/88300#issuecomment-936085371 exit is (conventionally) a library function, with _exit being the actual system call. I have checked the other references and they say "if the process terminated by calling `exti`". I think despite the slight imprecision (strictly, it should read iff ... `_exit`), this is clearer. Anyone who knows about the distinction between `exit` and `_exit` will not be confused. `_exit` is the correct traditional name for the system call, despite Linux calling it `exit_group` or `exit`: https://www.freebsd.org/cgi/man.cgi?query=_exit&sektion=2&n=1 Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-11-09Add a real tracking issue for `CommandExt::groups`Josh Stone-1/+1
2021-10-30Add #[must_use] to remaining std functions (O-Z)John Kugelman-0/+1
2021-10-23Rollup merge of #88300 - ijackson:exitstatusext-methods, r=yaahcMatthias Krüger-4/+4
Stabilise unix_process_wait_more, extra ExitStatusExt methods This stabilises the feature `unix_process_wait_more`. Tracking issue #80695, FCP needed. This was implemented in #79982 and merged in January.
2021-10-22Apply suggestions from code reviewJane Lusby-4/+4
2021-10-05Apply suggestions from code reviewJane Lusby-4/+4
2021-09-17modify std::os docs to be more consistentSachin Cherian-1/+3
> add intra doc links > add a usage example for the os::windows module
2021-08-24Stabilise unix_process_await_more, extra ExitStatusExt methodsIan Jackson-4/+4
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-08-19Factor out a common `RawFd`/`AsRawFd`/etc for Unix and WASI.Dan Gohman-1/+49
2021-08-19Add I/O safety trait impls for process::Stdio and process::Child.Dan Gohman-1/+11
2021-08-19I/O safety.Dan Gohman-7/+7
Introduce `OwnedFd` and `BorrowedFd`, and the `AsFd` trait, and implementations of `AsFd`, `From<OwnedFd>` and `From<T> for OwnedFd` for relevant types, along with Windows counterparts for handles and sockets. Tracking issue: - <https://github.com/rust-lang/rust/issues/87074> RFC: - <https://github.com/rust-lang/rfcs/blob/master/text/3128-io-safety.md>
2021-07-29Fix may not to appropriate might not or must notAli Malik-1/+1
2021-06-25Fix a few misspellings.Eric Huss-1/+1
2021-05-18Auto merge of #82973 - ijackson:exitstatuserror, r=yaahcbors-7/+46
Provide ExitStatusError Closes #73125 In MR #81452 "Add #[must_use] to [...] process::ExitStatus" we concluded that the existing arrangements in are too awkward so adding that `#[must_use]` is blocked on improving the ergonomics. I wrote a mini-RFC-style discusion of the approach in https://github.com/rust-lang/rust/issues/73125#issuecomment-771092741