about summary refs log tree commit diff
path: root/library/std/src/sys/pal/unix/process
AgeCommit message (Collapse)AuthorLines
2025-03-22std: move process implementations to `sys`joboet-3332/+0
As per #117276, this moves the implementations of `Process` and friends out of the `pal` module and into the `sys` module, removing quite a lot of error-prone `#[path]` imports in the process (hah, get it ;-)). I've also made the `zircon` module a dedicated submodule of `pal::unix`, hopefully we can move some other definitions there as well (they are currently quite a lot of duplications in `sys`). Also, the `ensure_no_nuls` function on Windows now lives in `sys::pal::windows` – it's not specific to processes and shared by the argument implementation.
2025-03-17Rollup merge of #137793 - NobodyXu:stablise-annoymous-pipe, r=joshtriplettJacob Pratt-0/+6
Stablize anonymous pipe Since #135822 is staled, I create this PR to stablise anonymous pipe Closes #127154 try-job: test-various
2025-03-17Rollup merge of #137621 - Berrysoft:cygwin-std, r=joboetJacob Pratt-1/+2
Add std support to cygwin target
2025-03-13Remove usage of legacy scheme paths on RedoxOSbjorn3-2/+0
The name:/path path syntax is getting phased out in favor of /scheme/name/path. Also using null: is no longer necessary as /dev/null is available on Redox OS too.
2025-03-14Mv os-specific trait impl of `Pipe*` into `std::os::*`Jiahao XU-0/+6
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2025-03-10Initial STD support for Cygwin王宇逸-1/+2
Signed-off-by: Ookiineko <chiisaineko@protonmail.com>
2025-03-10Add comments for #[no_sanitize(cfi)] in stdlibBastian Kersting-0/+2
2025-03-10Disable CFI for weakly linked syscallsBastian Kersting-0/+1
Currently, when enabling CFI via -Zsanitizer=cfi and executing e.g. std::sys::random::getrandom, we can observe a CFI violation. This is the case for all consumers of the std::sys::pal::weak::weak macro, as it is defining weak functions which don't show up in LLVM IR metadata. CFI fails for all these functions. Similar to other such cases in https://github.com/rust-lang/rust/issues/115199, this change stops emitting the CFI typecheck for consumers of the macro via the \#[no_sanitize(cfi)] attribute.
2025-03-07Rollup merge of #138034 - thaliaarchi:use-prelude-size-of, r=tgross35Matthias Krüger-10/+7
library: Use `size_of` from the prelude instead of imported Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the prelude instead of importing or qualifying them. These functions were added to all preludes in Rust 1.80. try-job: test-various try-job: x86_64-gnu try-job: x86_64-msvc-1
2025-03-06library: Use size_of from the prelude instead of importedThalia Archibald-10/+7
Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the prelude instead of importing or qualifying them. These functions were added to all preludes in Rust 1.80.
2025-03-05Rollup merge of #137463 - sunshowers:illumos-posix-spawn, r=Mark-Simulacrum许杰友 Jieyou Xu (Joe)-1/+16
[illumos] attempt to use posix_spawn to spawn processes illumos has `posix_spawn`, and the very newest versions also have `_addchdir`, so use that. POSIX standardized this function so I also added a weak symbol lookup for the non `_np` version. (illumos has both.) This probably also works on Solaris, but I don't have access to an installation to validate this so I decided to focus on illumos instead. This is a nice ~4x performance improvement for process creation. My go-to as usual is nextest against the clap repo, which acts as a stress test for process creation -- with [this commit]: ```console $ cargo nextest run -E 'not test(ui_tests) and not test(example_tests)' before: Summary [ 1.747s] 879 tests run: 879 passed, 2 skipped after: Summary [ 0.445s] 879 tests run: 879 passed, 2 skipped ``` [this commit]: https://github.com/clap-rs/clap/commit/fde45f9aea766fb8de46e3d46e6575f393c3b6b9
2025-02-28Use correct error message casing for `io::const_error`sNoratrieb-3/+3
Error messages are supposed to start with lowercase letters, but a lot of `io::const_error` messages did not. This fixes them to start with a lowercase letter. I did consider adding a const check for this to the macro, but some of them start with proper nouns that make sense to uppercase them. See https://doc.rust-lang.org/1.85.0/std/error/trait.Error.html
2025-02-23[illumos] attempt to use posix_spawn to spawn processesRain-1/+16
illumos has `posix_spawn`, and the very newest versions also have `_addchdir`, so use that. This is a nice ~4x performance improvement for process creation. My go-to as usual is nextest against the clap repo, which acts as a stress test for process creation -- with [this commit]: ```console $ cargo nextest run -E 'not test(ui_tests) and not test(example_tests)' before: Summary [ 1.747s] 879 tests run: 879 passed, 2 skipped after: Summary [ 0.445s] 879 tests run: 879 passed, 2 skipped ``` [this commit]: https://github.com/clap-rs/clap/commit/fde45f9aea766fb8de46e3d46e6575f393c3b6b9
2025-02-10Fix &&str and trailing commas in io::const_error!Thalia Archibald-1/+1
2025-02-10Use io::const_error! when possible over io::Error::newThalia Archibald-1/+1
2025-02-09Mark extern blocks as unsafeMichael Goulet-2/+2
2025-01-24add nto80 x86-64 and aarch64 targetAkhilTThomas-11/+3
Signed-off-by: Florian Bartels <Florian.Bartels@elektrobit.com>
2025-01-24Add new target for supporting Neutrino QNX 6.1 with `io-socket` network ↵Florian Bartels-3/+4
stack on aarch64 Signed-off-by: Florian Bartels <Florian.Bartels@elektrobit.com>
2024-12-02Use c"lit" for CStrings without unwrapKornel-1/+1
2024-11-26std: update internal uses of `io::const_error!`joboet-10/+10
2024-10-25library: consistently use American spelling for 'behavior'Ralf Jung-1/+1
2024-10-23[musl] use posix_spawn if a directory change was requestedRain-11/+43
Currently, not all libcs have the `posix_spawn_file_actions_addchdir_np` symbol available to them. So we attempt to do a weak symbol lookup for that function. But that only works if libc is a dynamic library -- with statically linked musl binaries the symbol lookup would never work, so we would never be able to use it even if the musl in use supported the symbol. Now that Rust has a minimum musl version of 1.2.3, all supported musl versions now include this symbol, so we can unconditionally expect it to be there. This symbol was added to libc in https://github.com/rust-lang/libc/pull/3949 -- use it here. I couldn't find any tests for whether the posix_spawn path is used, but I've verified with cargo-nextest that this change works. This is a substantial improvement to nextest's performance with musl. On my workstation with a Ryzen 7950x, against https://github.com/clap-rs/clap at 61f5ee514f8f60ed8f04c6494bdf36c19e7a8126: Before: ``` Summary [ 1.071s] 879 tests run: 879 passed, 0 skipped ``` After: ``` Summary [ 0.392s] 879 tests run: 879 passed, 0 skipped ``` Fixes #99740.
2024-10-08Update library/std/src/sys/pal/unix/process/process_vxworks.rsYuri Astrakhan-1/+1
Co-authored-by: Josh Stone <cuviper@gmail.com>
2024-10-08fix ref in process_vxworks.rsYuri Astrakhan-1/+1
2024-10-08Update library/std/src/sys/pal/unix/process/process_unix.rsYuri Astrakhan-1/+1
Co-authored-by: Josh Stone <cuviper@gmail.com>
2024-10-08Change a few `&Option<T>` into `Option<&T>`Yuri Astrakhan-3/+3
2024-09-25Use `&raw` in the standard libraryJosh Stone-8/+8
Since the stabilization in #127679 has reached stage0, 1.82-beta, we can start using `&raw` freely, and even the soft-deprecated `ptr::addr_of!` and `ptr::addr_of_mut!` can stop allowing the unstable feature. I intentionally did not change any documentation or tests, but the rest of those macro uses are all now using `&raw const` or `&raw mut` in the standard library.
2024-09-24Initial std library support for NuttXHuang Qi-3/+3
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-4/+4
2024-09-03Port std library to RTEMSJan Sommer-3/+3
2024-08-30Squashed `aarch64_unknown_nto_qnx700` supportYuri Astrakhan-4/+7
2024-08-09delete spacemonstercatss-2/+2
2024-08-09fix formatmonstercatss-4/+6
2024-08-09[SPARC] fix the name of signal 19 in sparc archMin-1/+9
2024-08-09[MIPS] fix the name of signal 19 in mipsMin-0/+3
2024-08-03Forbid unsafe_op_in_unsafe_fn in vxworks specific os and sys filesB I Mohammed Abbas-0/+1
2024-07-30Rollup merge of #128315 - zetanumbers:psvita-unsafe-in-unsafe, r=workingjubileeMatthias Krüger-0/+1
Fix vita build of std and forbid unsafe in unsafe in the os/vita module See #127747 r? `@workingjubilee` `@pheki` `@nikarh`
2024-07-29Reformat `use` declarations.Nicholas Nethercote-49/+33
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-28fix: psvita's std codeDaria Sukhonina-0/+1
2024-07-26Fix doc nitsJohn Arundel-1/+1
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-07-24Rollup merge of #127480 - biabbas:vxworks, r=workingjubileeMatthias Krüger-2/+7
Fix build failure on vxworks #127084 PR to address issue #127084 . 1. Skip `reset_segpipe` for vxworks 2. Return unimplemented error for vxworks from settimes and lchown 3. Temporarily skip dirfd for vxworks 4. Add allow unused unsafe on read_at and write_at functions in unix/fs.rs 5. Using cfg disable ON_BROKEN_PIPE_FLAG_USED and on_broken_pipe_flag_used() for vxworks 6. Remove old crate::syscommon::thread::min_stack() reference from process_vxworks.rs and update to set stack size of rtpthread Thank you.
2024-07-23Update process vxworks, set default stack size of 256 Kib for vxworks. User ↵B I Mohammed Abbas-2/+7
can set the stack size using RUST_MIN_STACK, with min size of libc::PTHREAD_STACK_MIN(4kib)
2024-07-21Fix warnings when checking armv6k-nintendo-3dsIan Chamberlain-1/+0
Also fix one instance of unsafe_op_in_unsafe_fn that's specific to horizon + vita - most others should be common with other code.
2024-07-12Rollup merge of #126827 - the8472:pidfd-spawn, r=workingjubileeMatthias Krüger-4/+113
Use pidfd_spawn for faster process spawning when a PidFd is requested glibc 2.39 added `pidfd_spawnp` and `pidfd_getpid` which makes it possible to get pidfds while staying on the CLONE_VFORK path. verified that vfork gets used with strace: ``` $ strace -ff -e pidfd_open,clone3,openat,execve,waitid,close ./x test std --no-doc -- pidfd [...] [pid 2820532] clone3({flags=CLONE_VM|CLONE_PIDFD|CLONE_VFORK|CLONE_CLEAR_SIGHAND, pidfd=0x7b7f885fec6c, exit_signal=SIGCHLD, stack=0x7b7f88aff000, stack_size=0x9000}strace: Process 2820533 attached <unfinished ...> [pid 2820533] execve("/home/the8472/bin/sleep", ["sleep", "1000"], 0x7ffdd0e268d8 /* 107 vars */) = -1 ENOENT (No such file or directory) [pid 2820533] execve("/home/the8472/.cargo/bin/sleep", ["sleep", "1000"], 0x7ffdd0e268d8 /* 107 vars */) = -1 ENOENT (No such file or directory) [pid 2820533] execve("/usr/local/bin/sleep", ["sleep", "1000"], 0x7ffdd0e268d8 /* 107 vars */) = -1 ENOENT (No such file or directory) [pid 2820533] execve("/usr/bin/sleep", ["sleep", "1000"], 0x7ffdd0e268d8 /* 107 vars */ <unfinished ...> [pid 2820532] <... clone3 resumed> => {pidfd=[3]}, 88) = 2820533 [pid 2820533] <... execve resumed>) = 0 [pid 2820532] openat(AT_FDCWD, "/proc/self/fdinfo/3", O_RDONLY|O_CLOEXEC) = 4 [pid 2820532] close(4) = 0 ``` Tracking issue: #82971
2024-07-01Remove unqualified import io:: Error for vxworks as all Error references are ↵B I Mohammed Abbas-1/+1
qualified in process_vxworks.rs
2024-06-25more fine-grained feature-detection for pidfd spawningThe 8472-21/+33
we now distinguish between pidfd_spawn support, pidfd-via-fork/exec and not-supported
2024-06-25document safety properties of the internal Process::new constructorThe 8472-0/+6
2024-06-25use pidfd_spawn for faster process creation when pidfds are requestedThe 8472-4/+95
2024-06-22Auto merge of #124101 - the8472:pidfd-methods, r=cuviperbors-101/+33
Add PidFd::{kill, wait, try_wait} #117957 changed `Child` kill/wait/try_wait to use its pidfd instead of the pid, when one is available. This PR extracts those implementations and makes them available on `PidFd` directly. The `PidFd` implementations differ significantly from the corresponding `Child` methods: * the methods can be called after the child has been reaped, which will result in an error but will be safe. This state is not observable in `Child` unless something stole the zombie child * the `ExitStatus` is not kept, meaning that only the first time a wait succeeds it will be returned * `wait` does not close stdin * `wait` only requires `&self` instead of `&mut self` since there is no state to maintain and subsequent calls are safe Tracking issue: #82971
2024-06-22to extract a pidfd we must consume the childThe 8472-2/+2
As long as a pidfd is on a child it can be safely reaped. Taking it would mean the child would now have to be awaited through its pid, but could also be awaited through the pidfd. This could then suffer from a recycling race.