summary refs log tree commit diff
path: root/library/std/src/sys
AgeCommit message (Collapse)AuthorLines
2025-08-01thread name in stack overflow messagejoboet-28/+77
2025-07-07Null terminate UNICODE_STRINGsChris Denton-2/+12
2025-06-20Rollup merge of #141990 - Qelxiros:141975-unix_send_signal, ↵Trevor Gross-8/+29
r=ChrisDenton,tgross35 Implement send_signal for unix child processes Tracking issue: rust-lang/rust#141975 There are two main differences between my implementation and the Public API section of the tracking issue. ~First, `send_signal` requires a mutable reference, like `Child::kill`.~ Second, `ChildExt` has `Sealed` as a supertrait, bringing it more in line with other extension traits like `CommandExt`. try-job: `dist-various*` try-job: `test-various*`
2025-06-19Auto merge of #141864 - Berrysoft:cygwin-path, r=ChrisDentonbors-172/+284
Handle win32 separator for cygwin paths This PR handles a issue that cygwin actually supports Win32 path, so we need to handle the Win32 prefix and separaters. r? `@mati865` cc `@jeremyd2019` ~~Not sure if I should handle the prefix like the windows target... Cygwin *does* support win32 paths directly going through the APIs, but I think it's not the recommended way.~~ Here I just use `cygwin_conv_path` because it handles both cygwin and win32 paths correctly and convert them into absolute POSIX paths. UPDATE: Windows path prefix is handled.
2025-06-18add ChildExt(::send_signal)Jeremy Smart-8/+29
2025-06-16Handle win32 separator & prefixes for cygwin paths王宇逸-172/+284
2025-06-15Windows: Use anonymous pipes in CommandChris Denton-86/+142
2025-06-08Rollup merge of #142053 - heiher:loong32-none, r=wesleywiserJubilee-1/+2
Add new Tier-3 targets: `loongarch32-unknown-none*` MCP: https://github.com/rust-lang/compiler-team/issues/865 NOTE: LoongArch32 ELF object support is available starting with object v0.37.0.
2025-06-06Add new Tier-3 targets: `loongarch32-unknown-none*`WANG Rui-1/+2
MCP: https://github.com/rust-lang/compiler-team/issues/865
2025-06-06Rollup merge of #142091 - thaliaarchi:aix-getenv, r=workingjubileeMatthias Krüger-1/+1
Fix AIX build Fix rust-lang/rust#141543. `getenv` was moved out of this file to `sys::env::getenv` in rust-lang/rust#140143. Replace its usage with `std::env::var_os`, the publicly exposed version. This matches the other usages of the same function in this file.
2025-06-05Fix AIX buildThalia Archibald-1/+1
2025-06-05Optimize `Seek::stream_len` impl for `File`Tobias Bucher-0/+39
It uses the file metadata on Unix with a fallback for files incorrectly reported as zero-sized. It uses `GetFileSizeEx` on Windows. This reduces the number of syscalls needed for determining the file size of an open file from 3 to 1.
2025-06-04Rollup merge of #141467 - cyrgani:const-empty-stringlikes, r=AmanieuMatthias Krüger-2/+2
make `OsString::new` and `PathBuf::new` unstably const Since #129041, `String::into_bytes` is `const`, which allows making `OsString::new` and `PathBuf::new` unstably const now. Not sure what the exact process for this is; does it need an ACP?
2025-06-03Rollup merge of #141455 - joboet:tls_exhaustion_abort, r=tgross35Matthias Krüger-11/+10
std: abort the process on failure to allocate a TLS key The panic machinery uses TLS, so panicking if no TLS keys are left can lead to infinite recursion (see https://github.com/rust-lang/rust/issues/140798#issuecomment-2872307377). Rather than having separate logic for the panic count and the thread name, just always abort the process if a TLS key allocation fails. This also has the benefit of aligning the key-based TLS implementation with the documentation, which does not mention that a panic could also occur because of resource exhaustion.
2025-05-31Auto merge of #141685 - orlp:inplace-tls-drop, r=joboetbors-29/+51
Do not move thread-locals before dropping Fixes rust-lang/rust#140816. I also (potentially) improved the speed of `get_or_init` a bit by having an explicit hot/cold path. We still move the value before dropping in the event of a recursive initialization (leading to double-initialization with one value being silently dropped). This is the old behavior, but changing this to panic instead would involve changing tests and also the other OS-specific `thread_local/os.rs` implementation, which is more than I'd like in this PR.
2025-05-30Address review comments.Orson Peters-0/+7
2025-05-28When replacing an old value we may not drop it in placeOrson Peters-12/+8
2025-05-28Add same unsafe bound on get_or_init_slowOrson Peters-2/+8
2025-05-28Add comments to diagnostic itemsPatrick-6-0/+6
2025-05-28Do not panic, maintain old behaviorOrson Peters-25/+17
2025-05-28Make pthread Mutex internals less publicPatrick-6-1/+1
2025-05-28Add diagnostic items to sys::MutexPatrick-6-0/+6
2025-05-28Improve safety comment, double-drop is not relevant hereOrson Peters-3/+4
2025-05-28Do not move thread-locals before droppingOrson Peters-32/+52
2025-05-27Rollup merge of #141312 - cberner:filelock_from, r=joshtriplettMatthias Krüger-8/+2
Add From<TryLockError> for io::Error Adds a `From` impl to make error propagation easier, as discussed in the tracking issue `TryLockError` is unstable under the "file_lock" feature. The related tracking issue is https://github.com/rust-lang/rust/issues/130994 This PR also cleanups the Windows implementation of `try_lock()` and `try_lock_shared()` as [discussed here](https://github.com/rust-lang/rust/pull/140718#discussion_r2076678485)
2025-05-26Rollup merge of #140936 - teor2345:wtf-surrogate-docs, r=workingjubileeJacob Pratt-3/+3
Clarify WTF-8 safety docs This PR is a follow-up to PR #140159, which clarifies ~~two things~~: - the WTF-8 safety comment [was confusing](https://github.com/rust-lang/rust/pull/140159#discussion_r2082766965), either surrogate condition is actually sufficient for safety, both are not required - ~~the private `os_str::Slice` type name is easily confused with `std::slice`~~ ~~Happy to bikeshed the `OsSlice` name, other alternatives are `OsStrSlice` and `StrSlice`. Now it's got a distinct name from `std::slice`, it's easy to search and replace.~~ cc ``@thaliaarchi`` ``@workingjubilee``
2025-05-24make `OsString::new` and `PathBuf::new` unstably constcyrgani-2/+2
2025-05-24Rollup merge of #139254 - Ayush1325:uefi-tcp4-connect, r=joboetMatthias Krüger-30/+178
std: sys: net: uefi: Implement TCP4 connect - Implement TCP4 connect using EFI_TCP4_PROTOCOL. - Tested on QEMU setup with connecting to TCP server on host.
2025-05-24Rollup merge of #141405 - RalfJung:GetUserProfileDirectoryW, r=ChrisDentonMatthias Krüger-2/+0
GetUserProfileDirectoryW is now documented to always store the size Update to match https://github.com/MicrosoftDocs/sdk-api/pull/1810 Also fix a bug in the Miri implementation while I am starting at that code... r? ```@ChrisDenton``` Fixes #141254
2025-05-23GetUserProfileDirectoryW is now documented to always store the sizeRalf Jung-2/+0
2025-05-23Rollup merge of #141398 - Dannyyy93:typos, r=NoratriebMatthias Krüger-2/+2
chore: fix typos in comment ## Fix Typos in Comments This PR addresses several typos in the Rust standard library's documentation comments: - In `library/std/src/sync/mpmc/list.rs`: Corrected "attemped" to "attempted" - In `library/std/src/sys/thread_local/guard/key.rs`: Fixed "defering" to "deferring" - In `library/std/src/sys/thread_local/guard/key.rs`: Fixed "futher" to "further" These changes improve documentation readability and consistency without affecting any functional code.
2025-05-23std: sys: net: uefi: Implement TCP4 connectAyush Singh-30/+178
- Implement TCP4 connect using EFI_TCP4_PROTOCOL. - Tested on QEMU setup with connecting to TCP server on host. Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-05-23std: abort the process on failure to allocate a TLS keyjoboet-11/+10
The panic machinery uses TLS, so panicking if no TLS keys are left can lead to infinite recursion (see https://github.com/rust-lang/rust/issues/140798#issuecomment-2872307377). Rather than having separate logic for the panic count and the thread name, just always abort the process if a TLS key allocation fails. This also has the benefit of aligning the key-based TLS implementation with the documentation, which does not mention that a panic could also occur because of resource exhaustion.
2025-05-23std: add safety comments to `CStringArray`joboet-0/+13
2025-05-23std: fix aliasing bug in UNIX process implementationjoboet-89/+129
`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-22docs: fix typosDannyyy93-2/+2
2025-05-20Remove unnecessary handling of ERROR_IO_PENDINGChristopher Berner-8/+2
try_lock() and try_lock_shared() do not need to handle these per the discussion in https://github.com/rust-lang/rust/pull/140718#discussion_r2076678485
2025-05-20Add `std::os::unix::process::CommandExt::chroot` to safely chroot a child ↵Josh Triplett-0/+29
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-19windows: document that we rely on an undocumented property of ↵Ralf Jung-0/+2
GetUserProfileDirectoryW
2025-05-18Rollup merge of #140628 - joboet:async_signal_safe, r=Mark-SimulacrumLeón Orell Valerian Liehr-58/+215
std: stop using TLS in signal handler TLS is not async-signal-safe, making its use in the signal handler used to detect stack overflows unsound (c.f. #133698). POSIX however lists two thread-specific identifiers that can be obtained in a signal handler: the current `pthread_t` and the address of `errno`. Since `pthread_equal` is not AS-safe, `pthread_t` should be considered opaque, so for our purposes, `&errno` is the only option. This however works nicely: we can use the address as a key into a map that stores information for each thread. This PR uses a `BTreeMap` protected by a spin lock to hold the guard page address and thread name and thus fixes #133698.
2025-05-17Auto merge of #138087 - tgross35:core-float-math, r=Amanieubors-4/+0
Initial implementation of `core_float_math` Since [1], `compiler-builtins` makes a certain set of math symbols weakly available on all platforms. This means we can begin exposing some of the related functions in `core`, so begin this process here. It is not possible to provide inherent methods in both `core` and `std` while giving them different stability gates, so standalone functions are added instead. This provides a way to experiment with the functionality while unstable; once it is time to stabilize, they can be converted to inherent. For `f16` and `f128`, everything is unstable so we can move the inherent methods. The following are included to start: * floor * ceil * round * round_ties_even * trunc * fract * mul_add * div_euclid * rem_euclid * powi * sqrt * abs_sub * cbrt These mirror the set of functions that we have in `compiler-builtins` since [1], with the exception of `powi` that has been there longer. Details for each of the changes is in the commit messages. Tracking issue: https://github.com/rust-lang/rust/issues/137578 [1]: https://github.com/rust-lang/compiler-builtins/pull/763 try-job: aarch64-gnu tru-job: armhf-gnu try-job: i686-msvc-1 try-job: test-various try-job: x86_64-mingw-1 try-job: x86_64-mingw-2
2025-05-17Rollup merge of #139103 - joboet:abort_dedup, r=tgross35Matthias Krüger-29/+17
deduplicate abort implementations Currently, the code for process aborts is duplicated across `panic_abort` and `std`. This PR uses `#[rustc_std_internal_symbol]` to make the `std` implementation available to `panic_abort` via the linker, thereby deduplicating the code.
2025-05-16disable the stack overflow handler on mirijoboet-29/+41
2025-05-16Rollup merge of #141013 - federico-terzi:feat/command_startupinfo_windows, ↵Matthias Krüger-0/+36
r=joboet Implement methods to set STARTUPINFO flags for Command API on Windows Implements https://github.com/rust-lang/rust/issues/141010
2025-05-15improve internal fastfail explainerjoboet-3/+2
2025-05-15deduplicate abort implementationsjoboet-29/+18
Currently, the code for process aborts is duplicated across `panic_abort` and `std`. This PR uses `#[rustc_std_internal_symbol]` to make the `std` implementation available to `panic_abort` via the linker, thereby deduplicating the code.
2025-05-15Fix confusing WTF surrogate safety docsteor-3/+3
2025-05-14wire up startupinfo methodsFederico Terzi-0/+36
2025-05-14Fix settimes for vxworksB I Mohammed Abbas-2/+1
2025-05-14Fix set_name for vxworks. Length of name should be truncated to ↵B I Mohammed Abbas-10/+2
VX_TASK_RENAME_LENGTH-1