Commit Graph

17 Commits

Author SHA1 Message Date
Deadbeef
7a79454de4 update internal send_signal comment 2025-06-27 18:24:42 +08:00
Jeremy Smart
b3914945ae add ChildExt(::send_signal) 2025-06-18 00:38:55 -04:00
joboet
89a90d6640 std: add safety comments to CStringArray 2025-05-23 17:09:02 +02:00
joboet
a467516c22 std: fix aliasing bug in UNIX process implementation
`CStringArray` contained both `CString`s and their pointers. Unfortunately, since `CString` uses `Box`, moving the `CString`s into the `Vec` can (under stacked borrows) invalidate the pointer to the string, meaning the resulting `Vec<*const c_char>` was, from an opsem perspective, unusable. This PR removes removes the `Vec<CString>` from `CStringArray`, instead recreating the `CString`/`CStr` from the pointers when necessary. Also,`CStringArray` is now used for the process args as well, the old implementation was suffering from the same kind of bug.
2025-05-23 17:09:00 +02:00
Josh Triplett
a3cf6f6408 Add std::os::unix::process::CommandExt::chroot to safely chroot a child 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 "/".
2025-05-20 18:25:05 +02:00
ivmarkov
392880c004 Fix regression from #140393 for espidf / horizon / nuttx / vita 2025-05-07 08:04:21 +00:00
Jacob Pratt
fe97fe45f8 Rollup merge of #140656 - joboet:fuchsia_pal, r=workingjubilee
collect all Fuchsia bindings into the `fuchsia` module

The Fuchsia bindings are currently spread out across multiple modules in `sys/pal/unix` leading to unnecessary duplication. This PR moves all of these definitions into `sys::pal::unix::fuchsia` and additionally:
* deduplicates the definitions
* makes the error names consistent
* marks `zx_thread_self` and `zx_clock_get_monotonic` as safe extern functions
* removes unused items (there's no need to maintain these bindings if we're not going to use them)
* removes the documentation for the definitions (contributors should always consult the platform documentation, duplicating that here is just an extra maintenance burden)

`@rustbot` ping fuchsia
2025-05-07 00:29:24 +00:00
joboet
7845c011dd collect all Fuchsia bindings into the fuchsia module
The Fuchsia bindings are currently spread out across multiple modules in `sys/pal/unix` leading to unnecessary duplication. This PR moves all of these definitions into `sys::pal::unix::fuchsia` and additionally:
* deduplicates the definitions
* makes the error names consistent
* marks some extern functions as safe
* removes unused items (there's no need to maintain these bindings if we're not going to use them)
* removes the documentation for the definitions (contributors should always consult the platform documentation, duplicating that here is just an extra maintenance burden)
2025-05-05 12:16:40 +02:00
joboet
5f145689b1 std: get rid of sys_common::process
Move the public `CommandEnvs` into the `process` module (and make it a wrapper type for an internal iterator type) and everything else into `sys::process` as per #117276.
2025-04-28 11:13:50 +02:00
Christopher Durham
4d93f60568 use generic Atomic type where possible
in core/alloc/std only for now, and ignoring test files

Co-authored-by: Pavel Grigorenko <GrigorenkoPV@ya.ru>
2025-04-27 02:18:08 +03:00
Matthias Krüger
f3641df491 Rollup merge of #140143 - thaliaarchi:move-env-pal, r=joboet
Move `sys::pal::os::Env` into `sys::env`

Although `Env` (as `Vars`), `Args`, path functions, and OS constants are publicly exposed via `std::env`, their implementations are each self-contained. Keep them separate in `std::sys` and make a new module, `sys::env`, for `Env`.

Also fix `unsafe_op_in_unsafe_fn` for Unix and update the `!DynSend` and `!DynSync` impls which had grown out of sync with the platforms (see #48005 for discussion on that).

r? joboet

Tracked in #117276.
2025-04-25 07:50:25 +02:00
Chris Denton
1586660fb2 Rollup merge of #139617 - Berrysoft:cygwin-posix-spawn, r=joboet
Use posix_spawn on cygwin

r? ``@joboet``

Depends on:
- [x] https://github.com/rust-lang/libc/pull/4387
- [x] https://github.com/rust-lang/rust/pull/140081
2025-04-22 15:24:05 +00:00
Thalia Archibald
90fe2805df Move sys::pal::os::Env into sys::env
Although `Env` (as `Vars`), `Args`, path functions, and OS constants are
publicly exposed via `std::env`, their implementations are each
self-contained. Keep them separate in `std::sys` and make a new module,
`sys::env`, for `Env`.
2025-04-21 20:56:43 -07:00
Bastian Kersting
068a332459 cfi: Remove #[no_sanitize(cfi)] for extern weak functions
Previously (https://github.com/rust-lang/rust/pull/115200,
https://github.com/rust-lang/rust/pull/138002), we
added `#[no_sanitize(cfi)]` to all code paths that call to a weakly
linked function.

In https://github.com/rust-lang/rust/pull/138349 we fixed the root cause
for this issue, which means we can now remove the corresponding
attributes.
2025-04-11 10:15:55 +00:00
Berrysoft
7aab011dbb Use posix_spawn on cygwin 2025-04-10 15:12:19 +08:00
Mads Marquart
a7bafc0afc Change the syntax of the internal weak! macro
Change the syntax to include parameter names and a trailing semicolon.

Motivation:
- Mirror the `syscall!` macro.
- Allow rustfmt to format it (when wrapped in parentheses).
- For better documentation (having the parameter names available in
  the source code is a bit nicer).
- Allow future improvements to this macro where we can sometimes use the
  symbol directly when it's statically known to be available.
2025-03-26 16:25:05 +01:00
joboet
89f85cbfa7 std: move process implementations to sys
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-22 12:42:34 +01:00