summary refs log tree commit diff
path: root/library/std/src/sys/unix/process
AgeCommit message (Collapse)AuthorLines
2023-08-09Rollup merge of #113939 - the8472:pidfd-from-child, r=Mark-SimulacrumMatthias Krüger-90/+156
open pidfd in child process and send to the parent via SOCK_SEQPACKET+CMSG This avoids using `clone3` when a pidfd is requested while still getting it in a 100% race-free manner by passing it up from the child process. This should solve most concerns in #82971
2023-08-08open pidfd in child process and send to the parent via SOCK_SEQPACKET+CMSGThe 8472-90/+156
This is a 100% race-free way to obtain a child's pidfd while avoiding `clone3`.
2023-08-08Rollup merge of #106425 - ijackson:exit-status-default, r=dtolnayMatthias Krüger-4/+4
Make ExitStatus implement Default And, necessarily, make it inhabited even on platforms without processes. I noticed while preparing https://github.com/rust-lang/rfcs/pull/3362 that there was no way for anyone to construct an `ExitStatus`. This would be insta-stable so needs an FCP.
2023-08-07impl Default for ExitStatusIan Jackson-4/+4
2023-07-06Rollup merge of #113334 - fmease:revert-lexing-c-str-lits, r=compiler-errorsfee1-dead-4/+5
Revert the lexing of `c"…"` string literals Fixes \[after beta-backport\] #113235. Further progress is tracked in #113333. This PR *manually* reverts parts of #108801 (since a git-revert would've been too coarse-grained & messy) and git-reverts #111647. CC `@fee1-dead` (#108801) `@klensy` (#111647) r? `@compiler-errors` `@rustbot` label F-c_str_literals beta-nominated
2023-07-05Revert "use c literals in library"León Orell Valerian Liehr-4/+5
This reverts commit f212ba6d6d60963c8101bb24fc3e53fca80c046f.
2023-07-05Auto merge of #112594 - ChrisDenton:process=-kill, r=Amanieubors-10/+4
Return `Ok` on kill if process has already exited This will require an FCP from `@rust-lang/libs-api.` Fixes #112423. See that issue for more details.
2023-07-01Return `Ok` on kill if process has already exitedChris Denton-10/+4
2023-06-21Actually save all the filesThom Chiovoloni-7/+6
2023-06-21Avoid fork/exec spawning on tvOS/watchOS, as those functions are marked as ↵Thom Chiovoloni-4/+48
prohibited
2023-06-13fix: get the l4re target working againHenrik Böving-1/+17
2023-06-03Auto merge of #109432 - flba-eb:108594_forkspawn_exponential_backoff, ↵bors-14/+62
r=workingjubilee QNX Neutrino: exponential backoff when fork/spawn needs a retry Fixes #108594: When retrying, sleep with an exponential duration. When sleep duration is lower than minimum possible sleeping time, yield instead (this will not be often due to the exponential increase of duration). Minimum possible sleeping time is determined using `libc::clock_getres` but only when spawn/fork failed the first time in a request. This is cached using a LazyLock. CC `@gh-tr` r? `@workingjubilee` `@rustbot` label +O-neutrino
2023-06-02Only determine clock res once; give up before sleeping more than 1 secondFlorian Bartels-23/+37
2023-06-02Retry to fork/spawn with exponential backoffFlorian Bartels-10/+44
2023-05-31use c literals in libraryklensy-5/+4
2023-05-13refactor: Remove redundant, private OsStr::bytesEd Page-2/+2
2023-05-07PS Vita std supportNikolay Arhipov-1/+1
2023-04-26Spelling library/Josh Soref-2/+2
* advance * aligned * borrowed * calculate * debugable * debuggable * declarations * desugaring * documentation * enclave * ignorable * initialized * iterator * kaboom * monomorphization * nonexistent * optimizer * panicking * process * reentrant * rustonomicon * the * uninitialized Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-12remove some unneeded importsKaDiWa-2/+0
2023-02-28Retry to spawn/fork up to 3 times when it failed because of an interruptionFlorian Bartels-2/+64
2023-02-28Add QNX Neutrino support to libstdFlorian Bartels-3/+7
Co-authored-by: gh-tr <troach@qnx.com>
2023-01-18signal update string representation for haiku.David Carlier-0/+2
2023-01-14Remove various double spaces in source comments.André Vennberg-14/+14
2023-01-11Change `src/test` to `tests` in source files, fix tidy and testsAlbert Larsan-1/+1
2022-12-27More verbose `Debug` implementation of `std::process:Command`kraktus-7/+60
based on commit: https://github.com/zackmdavis/rust/commit/ccc019aabfdd550944c049625e66c92c815ea1d0 from https://github.com/zackmdavis close https://github.com/rust-lang/rust/issues/42200 Add env variables and cwd to the shell-like debug output. Also use the alternate syntax to display a more verbose display, while not showing internal fields and hiding fields when they have their default value.
2022-12-17Rollup merge of #105458 - Ayush1325:blocking_spawn, r=Mark-SimulacrumMatthias Krüger-0/+19
Allow blocking `Command::output` ### Problem Currently, `Command::output` is internally implemented using `Command::spawn`. This is problematic because some targets (like UEFI) do not actually support multitasking and thus block while the program is executing. This coupling does not make much sense as `Command::output` is supposed to block until the execution is complete anyway and thus does not need to rely on a non-blocking `Child` or any other intermediate. ### Solution This PR moves the implementation of `Command::output` to `std::sys`. This means targets can choose to implement only `Command::output` without having to implement `Command::spawn`. ### Additional Information This was originally conceived when working on https://github.com/rust-lang/rust/pull/100316. Currently, the only target I know about that will benefit from this change is UEFI. This PR can also be used to implement more efficient `Command::output` since the intermediate `Process` is not actually needed anymore, but that is outside the scope of this PR. Since this is not a public API change, I'm not sure if an RFC is needed or not.
2022-12-12explain mem::forget(env_lock) in fork/execRalf Jung-3/+4
2022-12-11Implement blocking outputAyush Singh-0/+19
This allows decoupling `Command::spawn` and `Command::output`. This is useful for targets which do support launching programs in blocking mode but do not support multitasking (Eg: UEFI). This was originally conceived when working on https://github.com/rust-lang/rust/pull/100316 Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2022-10-20Change process spawning to inherit the parent's signal mask by defaultRain-66/+87
Previously, the signal mask is always reset when a child process is started. This breaks tools like `nohup` which expect `SIGHUP` to be blocked. With this change, the default behavior changes to inherit the signal mask. This also changes the signal disposition for `SIGPIPE` to only be changed if the `#[unix_sigpipe]` attribute isn't set.
2022-10-14more dupe word typosRageking8-1/+1
2022-09-20Remove use of `io::ErrorKind::Other` in stdPatiga-2/+2
The documentation states that this `ErrorKind` is not used by the standard library. Instead, `io::ErrorKind::Uncategorized` should be used.
2022-08-28Use posix_spawn for absolute paths on macOSRain-1/+60
Currently, on macOS, Rust never uses the fast posix_spawn path if a directory change is requested due to a bug in Apple's libc. However, the bug is only triggered if the program is a relative path. This PR makes it so that the fast path continues to work if the program is an absolute path or a lone filename. This was an alternative proposed in https://github.com/rust-lang/rust/pull/80537#issue-776674009, and it makes a measurable performance difference in some of my code that spawns thousands of processes.
2022-08-21Fix redundant comparisonThom Chiovoloni-1/+1
2022-08-19Align android `sigaddset` impl with the reference impl from BionicThom Chiovoloni-3/+23
2022-06-13Horizon OS STD supportMeziu-9/+7
Co-authored-by: Ian Chamberlain <ian.h.chamberlain@gmail.com> Co-authored-by: Mark Drobnak <mark.drobnak@gmail.com>
2022-06-05Remove SIGIO reference on HaikuRyan Zoeller-0/+1
Haiku doesn't define SIGIO. The nix crate already employs this workaround: https://github.com/nix-rust/nix/blob/5dedbc7850448ae3922ab0a833f3eb971bf7e25f/src/sys/signal.rs#L92-L94
2022-06-03Auto merge of #95833 - notriddle:notriddle/human-readable-signals, r=yaahcbors-6/+82
std: `<ExitStatus as Display>::fmt` name the signal it died from Related to #95601
2022-06-02Fix MIPS-specific signal bugMichael Howell-1/+10
2022-06-01std: show signal number along with nameMichael Howell-46/+50
2022-05-09Use Rust 2021 prelude in std itself.Mara Bos-5/+0
2022-04-25Remove references to git.ioEric Huss-1/+2
2022-04-23std: `<ExitStatus as Display>::fmt` name the signal it died fromMichael Howell-3/+66
2022-04-17Auto merge of #93530 - anonion0:pthread_sigmask_fix, r=JohnTitorbors-4/+5
fix error handling for pthread_sigmask(3) Errors from `pthread_sigmask(3)` were handled using `cvt()`, which expects a return value of `-1` on error and uses `errno`. However, `pthread_sigmask(3)` returns `0` on success and an error number otherwise. Fix it by replacing `cvt()` with `cvt_nz()`.
2022-04-17move import to fix warning with emscripten targetRalf Sager-1/+2
2022-03-19Rollup merge of #93858 - krallin:process-process_group, r=dtolnayDylan DPC-2/+80
Add a `process_group` method to UNIX `CommandExt` - Tracking issue: #93857 - RFC: https://github.com/rust-lang/rfcs/pull/3228 Add a `process_group` method to `std::os::unix::process::CommandExt` that allows setting the process group id (i.e. calling `setpgid`) in the child, thus enabling users to set process groups while leveraging the `posix_spawn` fast path.
2022-03-19Rollup merge of #92612 - atopia:update-lib-l4re, r=dtolnayDylan DPC-1/+4
Update stdlib for the l4re target This PR contains the work by ``@humenda`` and myself to update standard library support for the x86_64-unknown-l4re-uclibc tier 3 target, split out from humenda/rust as requested in #85967. The changes have been rebased on current master and updated in follow up commits by myself. The publishing of the changes is authorized and preferred by the original author. To preserve attribution, when standard library changes were introduced as part of other changes to the compiler, I have kept the changes concerning the standard library and altered the commit messages as indicated. Any incompatibilities have been remedied in follow up commits, so that the PR as a whole should result in a clean update of the target.
2022-03-17feat: Add use of bool::then in sys/unix/processwcampbell-3/+3
Remove else { None } in favor of using bool::then()
2022-03-14Add a `process_group` method to UNIX `CommandExt`Thomas Orozco-2/+80
2022-03-10Use implicit capture syntax in format_argsT-O-R-U-S-8/+8
This updates the standard library's documentation to use the new syntax. The documentation is worthwhile to update as it should be more idiomatic (particularly for features like this, which are nice for users to get acquainted with). The general codebase is likely more hassle than benefit to update: it'll hurt git blame, and generally updates can be done by folks updating the code if (and when) that makes things more readable with the new format. A few places in the compiler and library code are updated (mostly just due to already having been done when this commit was first authored).
2022-03-09drop unused libc imports on L4ReBenjamin Lamowski-1/+4
As a capability-based microkernel OS, L4Re only has incomplete support for POSIX APIs, in particular it does not implement UIDs and GIDs.