summaryrefslogtreecommitdiff
path: root/library/std/src/sys/unix/process
Commit message (Collapse)AuthorAgeFilesLines
* PS Vita std supportNikolay Arhipov2023-05-071-1/+1
|
* Spelling library/Josh Soref2023-04-262-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>
* remove some unneeded importsKaDiWa2023-04-121-2/+0
|
* Retry to spawn/fork up to 3 times when it failed because of an interruptionFlorian Bartels2023-02-281-2/+64
|
* Add QNX Neutrino support to libstdFlorian Bartels2023-02-281-3/+7
| | | | Co-authored-by: gh-tr <troach@qnx.com>
* signal update string representation for haiku.David Carlier2023-01-181-0/+2
|
* Remove various double spaces in source comments.André Vennberg2023-01-144-14/+14
|
* Change `src/test` to `tests` in source files, fix tidy and testsAlbert Larsan2023-01-111-1/+1
|
* More verbose `Debug` implementation of `std::process:Command`kraktus2022-12-271-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.
* Rollup merge of #105458 - Ayush1325:blocking_spawn, r=Mark-SimulacrumMatthias Krüger2022-12-174-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.
| * Implement blocking outputAyush Singh2022-12-114-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>
* | explain mem::forget(env_lock) in fork/execRalf Jung2022-12-121-3/+4
|/
* Change process spawning to inherit the parent's signal mask by defaultRain2022-10-203-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.
* more dupe word typosRageking82022-10-141-1/+1
|
* Remove use of `io::ErrorKind::Other` in stdPatiga2022-09-201-2/+2
| | | | | | The documentation states that this `ErrorKind` is not used by the standard library. Instead, `io::ErrorKind::Uncategorized` should be used.
* Use posix_spawn for absolute paths on macOSRain2022-08-283-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.
* Fix redundant comparisonThom Chiovoloni2022-08-211-1/+1
|
* Align android `sigaddset` impl with the reference impl from BionicThom Chiovoloni2022-08-191-3/+23
|
* Horizon OS STD supportMeziu2022-06-132-9/+7
| | | | | Co-authored-by: Ian Chamberlain <ian.h.chamberlain@gmail.com> Co-authored-by: Mark Drobnak <mark.drobnak@gmail.com>
* Remove SIGIO reference on HaikuRyan Zoeller2022-06-051-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
* Auto merge of #95833 - notriddle:notriddle/human-readable-signals, r=yaahcbors2022-06-032-6/+82
|\ | | | | | | | | | | std: `<ExitStatus as Display>::fmt` name the signal it died from Related to #95601
| * Fix MIPS-specific signal bugMichael Howell2022-06-021-1/+10
| |
| * std: show signal number along with nameMichael Howell2022-06-012-46/+50
| |
| * std: `<ExitStatus as Display>::fmt` name the signal it died fromMichael Howell2022-04-232-3/+66
| |
* | Use Rust 2021 prelude in std itself.Mara Bos2022-05-095-5/+0
| |
* | Remove references to git.ioEric Huss2022-04-251-1/+2
| |
* | Auto merge of #93530 - anonion0:pthread_sigmask_fix, r=JohnTitorbors2022-04-172-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()`.
| * move import to fix warning with emscripten targetRalf Sager2022-04-171-1/+2
| |
| * fix error handling for pthread_sigmask(3)Ralf Sager2022-01-312-5/+5
| | | | | | | | | | | | | | | | 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().
* | Rollup merge of #93858 - krallin:process-process_group, r=dtolnayDylan DPC2022-03-193-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.
| * | Add a `process_group` method to UNIX `CommandExt`Thomas Orozco2022-03-143-2/+80
| | |
* | | Rollup merge of #92612 - atopia:update-lib-l4re, r=dtolnayDylan DPC2022-03-191-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.
| * | | drop unused libc imports on L4ReBenjamin Lamowski2022-03-091-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.
* | | | feat: Add use of bool::then in sys/unix/processwcampbell2022-03-171-3/+3
| | | | | | | | | | | | | | | | Remove else { None } in favor of using bool::then()
* | | | Use implicit capture syntax in format_argsT-O-R-U-S2022-03-103-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).
* | | Provide C FFI types via core::ffi, not just in stdJosh Triplett2022-03-013-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ability to interoperate with C code via FFI is not limited to crates using std; this allows using these types without std. The existing types in `std::os::raw` become type aliases for the ones in `core::ffi`. This uses type aliases rather than re-exports, to allow the std types to remain stable while the core types are unstable. This also moves the currently unstable `NonZero_` variants and `c_size_t`/`c_ssize_t`/`c_ptrdiff_t` types to `core::ffi`, while leaving them unstable.
* | | Rollup merge of #93445 - yaahc:exitcode-constructor, r=dtolnayYuki Okushi2022-02-091-0/+6
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add From<u8> for ExitCode This should cover a mostly cross-platform subset of supported exit codes. We decided to stick with `u8` initially since its the common subset between all platforms that we support (excluding wasm which I think only works with `true` or `false`). Posix is supposed to take i32s, but in practice many unix platforms mask out all but the low 8 bits or in some cases the 8-15th bits. Windows takes a u32 instead of an i32. Bourne-compatible shells also report signals as exitcode 128 + `signal_no`, so there's some ambiguity there when returning exit codes > 127, but it is possible to disambiguate them on the other side so we decided against restricting the possible codes further than to `u8`. ## Related - Detailed analysis of exit code support on various platforms: https://internals.rust-lang.org/t/mini-pre-rfc-redesigning-process-exitstatus/5426 - https://github.com/rust-lang/rust/issues/48711 - https://github.com/rust-lang/rust/issues/43301 - https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Termination.2FExit.20Status.20Stabilization
| * | | Add From<u8> for ExitCodeJane Lusby2022-02-061-0/+6
| |/ / | | | | | | | | | This should cover a mostly cross-platform subset of supported exit codes.
* | | Hide Repr details from io::Error, and rework `io::Error::new_const`.Thom Chiovoloni2022-02-043-20/+17
|/ /
* | Old versions of Android generate SIGSEGV from libc::abortAmanieu d'Antras2022-01-211-1/+6
| |
* | Fix a bunch of typosFrank Steffahn2021-12-141-1/+1
| |
* | Refactor weak symbols in std::sys::unixJosh Stone2021-11-121-2/+2
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes a few changes to the weak symbol macros in `sys::unix`: - `dlsym!` is added to keep the functionality for runtime `dlsym` lookups, like for `__pthread_get_minstack@GLIBC_PRIVATE` that we don't want to show up in ELF symbol tables. - `weak!` now uses `#[linkage = "extern_weak"]` symbols, so its runtime behavior is just a simple null check. This is also used by `syscall!`. - On non-ELF targets (macos/ios) where that linkage is not known to behave, `weak!` is just an alias to `dlsym!` for the old behavior. - `raw_syscall!` is added to always call `libc::syscall` on linux and android, for cases like `clone3` that have no known libc wrapper. The new `weak!` linkage does mean that you'll get versioned symbols if you build with a newer glibc, like `WEAK DEFAULT UND statx@GLIBC_2.28`. This might seem problematic, but old non-weak symbols can tie the build to new versions too, like `dlsym@GLIBC_2.34` from their recent library unification. If you build with an old glibc like `dist-x86_64-linux` does, you'll still get unversioned `WEAK DEFAULT UND statx`, which may be resolved based on the runtime glibc. I also found a few functions that don't need to be weak anymore: - Android can directly use `ftruncate64`, `pread64`, and `pwrite64`, as these were added in API 12, and our baseline is API 14. - Linux can directly use `splice`, added way back in glibc 2.5 and similarly old musl. Android only added it in API 21 though.
* Rollup merge of #90704 - ijackson:exitstatus-comments, r=joshtriplettMatthias Krüger2021-11-121-0/+3
|\ | | | | | | | | | | Unix ExitStatus comments and a tiny docs fix Some nits left over from #88300
| * unix::ExitStatus: Add comment saying that it's a wait statusIan Jackson2021-11-111-0/+3
| | | | | | | | | | | | With cross-reference. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
* | Also note tool expectations of fork vs clone3Josh Stone2021-11-051-0/+2
| | | | | | | | Co-authored-by: Josh Triplett <josh@joshtriplett.org>
* | Update another comment on fork vs. clone3Josh Stone2021-11-051-2/+2
| |
* | Only use `clone3` when needed for pidfdJosh Stone2021-11-051-7/+6
|/ | | | | | In #89522 we learned that `clone3` is interacting poorly with Gentoo's `sandbox` tool. We only need that for the unstable pidfd extensions, so otherwise avoid that and use a normal `fork`.
* [fuchsia] Update process info structJoshua Seaton2021-10-151-4/+7
| | | | | | | | The fuchsia platform is in the process of softly transitioning over to using a new value for ZX_INFO_PROCESS with a new corresponding struct. This change migrates libstd. See fxrev.dev/510478 and fxbug.dev/30751 for more detail.
* Rollup merge of #88828 - FabianWolff:issue-88585, r=dtolnayManish Goregaokar2021-10-051-3/+13
|\ | | | | | | | | | | | | | | | | | | | | Use `libc::sigaction()` instead of `sys::signal()` to prevent a deadlock Fixes #88585. POSIX [specifies](https://man7.org/linux/man-pages/man3/fork.3p.html) that after forking, > to avoid errors, the child process may only execute async-signal-safe operations until such time as one of the exec functions is called. Rust's standard library does not currently adhere to this, as evidenced by #88585. The child process calls [`sys::signal()`](https://github.com/rust-lang/rust/blob/7bf0736e130e2203c58654f7353dbf9575e49d5c/library/std/src/sys/unix/android.rs#L76), which on Android calls [`libc::dlsym()`](https://github.com/rust-lang/rust/blob/7bf0736e130e2203c58654f7353dbf9575e49d5c/library/std/src/sys/unix/weak.rs#L101), which is [**not**](https://man7.org/linux/man-pages/man7/signal-safety.7.html) async-signal-safe, and in fact causes a deadlock in the example in #88585. I think the easiest solution here would be to just call `libc::sigaction()` instead, which [is](https://man7.org/linux/man-pages/man7/signal-safety.7.html) async-signal-safe, provides the functionality we need, and is apparently available on all Android versions because it is also used e.g. [here](https://github.com/rust-lang/rust/blob/7bf0736e130e2203c58654f7353dbf9575e49d5c/library/std/src/sys/unix/stack_overflow.rs#L112-L114).
| * Call `libc::sigaction()` only on AndroidFabian Wolff2021-10-011-3/+14
| |