about summary refs log tree commit diff
path: root/library/std/src/os
AgeCommit message (Collapse)AuthorLines
2025-08-16library: Migrate from `cfg_if` to `cfg_select`Josh Triplett-10/+12
Migrate the standard library from using the external `cfg_if` crate to using the now-built-in `cfg_select` macro. This does not yet eliminate the dependency from `library/std/Cargo.toml`, because while the standard library itself no longer uses `cfg_if`, it also incorporates the `backtrace` crate, which does. Migration assisted by the following vim command (after selecting the full `cfg_if!` invocation): ``` '<,'>s/\(cfg_if::\)\?cfg_if/cfg_select/ | '<,'>s/^\( *\)} else {/\1}\r\1_ => {/c | '<,'>s/^\( *\)} else if #\[cfg(\(.*\))\] /\1}\r\1\2 => /e | '<,'>s/if #\[cfg(\(.*\))\] {/\1 => {/e ``` This is imperfect, but substantially accelerated the process. This prompts for confirmation on the `} else {` since that can also appear inside one of the arms. This also requires manual intervention to handle any multi-line conditions.
2025-07-11Rollup merge of #142391 - LevitatingBusinessMan:setsid, r=workingjubileeMatthias Krüger-0/+8
rust: library: Add `setsid` method to `CommandExt` trait Add a setsid method to the CommandExt trait so that callers can create a process in a new session and process group whilst still using the POSIX spawn fast path. Tracking issue: rust-lang/rust#105376 ACP: https://github.com/rust-lang/libs-team/issues/184 This PR was previously submitted by ``@HarveyHunt`` (whom I marked as Co-Author in the commit message) in rust-lang/rust#105377. However that PR went stale. I applied the [suggestion](https://github.com/rust-lang/rust/pull/105377/files/231d19fcbfe155b2e85116865adae4253380ff1f#r1893457943) to change the function signature to `fn setsid(&mut self, setsid: bool) -> &mut Command`.
2025-07-10rust: library: Add setsid method to CommandExt traitLevitatingBusinessMan (Rein Fernhout)-0/+8
Add a setsid method to the CommandExt trait so that callers can create a process in a new session and process group whilst still using the POSIX spawn fast path. Co-Authored-By: Harvey Hunt <harveyhunt@fb.com>
2025-07-03setup CI and tidy to use typos for spellchecking and fix few typosklensy-1/+1
2025-07-01Update version placeholdersJosh Stone-8/+8
2025-06-29Rollup merge of #142889 - nabijaczleweli:rusts, r=Mark-SimulacrumMatthias Krüger-7/+5
Clarify doc comment on unix OpenOptions
2025-06-28Rollup merge of #123476 - devnexen:std_net_solaris_exclbind, r=Mark-SimulacrumMatthias Krüger-0/+102
std::net: adding `unix_socket_exclbind` feature for solaris/illumos. allows to have a tigher control over the binding exclusivness of the socket. ACP: https://github.com/rust-lang/libs-team/issues/366
2025-06-28"set by Rusts options". Remove misleading always-true if cfg!(unix). Drop ↵наб-7/+5
#![feature(rustc_private)]
2025-06-24Rollup merge of #140005 - mlowicki:patch-1, r=tgross35Guillaume Gomez-1/+22
Set MSG_NOSIGNAL for UnixStream https://github.com/rust-lang/rust/issues/139956 Same logic as for https://github.com/rust-lang/rust/blob/1f76d219c906f0112bb1872f33aa977164c53fa6/library/std/src/sys/net/connection/socket.rs#L399-L405.
2025-06-20Rollup merge of #141990 - Qelxiros:141975-unix_send_signal, ↵Trevor Gross-0/+38
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-18add ChildExt(::send_signal)Jeremy Smart-0/+38
2025-06-16Set MSG_NOSIGNAL for UnixSteamMichał Łowicki-1/+22
https://github.com/rust-lang/rust/issues/139956 fix
2025-06-12Delegate `<SocketAddr as Debug>` to `ByteStr`Tamir Duberstein-4/+14
This allows UTF-8 characters to be printed without escapes, rather than just ASCII.
2025-06-10std::net: adding `unix_socket_exclbind` feature for solaris/illumos.David Carlier-0/+102
allows to have a tigher control over the binding exclusivness of the socket.
2025-06-09Rollup merge of #129121 - devnexen:stabilize_ext_linux_tcp_layer, r=tgross35Matthias Krüger-10/+8
Stabilize `tcp_quickack` to stabilise the quickack part for now, tcp_deferaccept had been added at a later stage. The related API calls are the following ```rust // std::os::linux::net // sealed trait, implemented for std::net::TcpStream pub trait TcpStreamExt: Sealed{ fn quickack(&self) -> io::Result<bool>; fn set_quickack(&self, quickack: bool) -> io::Result<()>; } ``` Closes: https://github.com/rust-lang/rust/issues/96256
2025-06-06Add new Tier-3 targets: `loongarch32-unknown-none*`WANG Rui-0/+1
MCP: https://github.com/rust-lang/compiler-team/issues/865
2025-05-23Rollup merge of #141019 - ehuss:android-doctest-xcompile, r=Mark-SimulacrumMatthias Krüger-0/+15
Update std doctests for android This updates some doctests that fail to run on android. We will soon be supporting cross-compiled doctests, and the `arm-android` job fails to run these tests. In summary: - Android re-exports some traits from linux under a different path. - Android doesn't seem to have common unix utilities like `true`, `false`, or `whoami`, so these are disabled.
2025-05-21Apply suggestions from code reviewJosh Triplett-5/+5
Link `Command::current_dir`. Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
2025-05-20`CommandExt::chroot`: Add tracking issueJosh Triplett-1/+1
2025-05-20`CommandExt::chroot`: Document difference to underlying `chroot`Josh Triplett-3/+5
2025-05-20Add `std::os::unix::process::CommandExt::chroot` to safely chroot a child ↵Josh Triplett-0/+16
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-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-16Rollup merge of #140984 - mlowicki:patch-2, r=ibraheemdevMatthias Krüger-2/+2
fix doc for UnixStream Doc example was using `UdpSocket` instead of `UnixStream`.
2025-05-14Update std doctests for androidEric Huss-0/+15
This updates some doctests that fail to run on android. We will soon be supporting cross-compiled doctests, and the `arm-android` job fails to run these tests. In summary: - Android re-exports some traits from linux under a different path. - Android doesn't seem to have common unix utilities like `true`, `false`, or `whoami`, so these are disabled.
2025-05-14wire up startupinfo methodsFederico Terzi-0/+36
2025-05-13fix doc for UnixStreamMichał Łowicki-2/+2
2025-05-10Remove `stable` attribute from wasi fs (read_exact|write_all)_atPaolo Barbolini-2/+0
2025-04-27use generic Atomic type where possibleChristopher Durham-16/+16
in core/alloc/std only for now, and ignoring test files Co-authored-by: Pavel Grigorenko <GrigorenkoPV@ya.ru>
2025-04-23Impl new API `std::os::unix::fs::mkfifo` under feature `unix_fifo`Jiahao XU-0/+56
Tracking issue #139324 Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2025-04-09replace version placeholderBoxy-24/+24
2025-03-23Trusty: Fix build for anonymous pipes and std::sys::processThalia Archibald-4/+14
PRs #136842 (Add libstd support for Trusty targets), #137793 (Stablize anonymous pipe), and #136929 (std: move process implementations to `sys`) merged around the same time, so update Trusty to take them into account.
2025-03-17Rollup merge of #137793 - NobodyXu:stablise-annoymous-pipe, r=joshtriplettJacob Pratt-1/+171
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-2/+122
Add std support to cygwin target
2025-03-14Rollup merge of #136001 - hkBst:patch-21, r=cuviperJacob Pratt-49/+75
Overhaul examples for PermissionsExt This fixes #91707 by including one overarching example, instead of the small examples that can be misleading.
2025-03-14Mv os-specific trait impl of `Pipe*` into `std::os::*`Jiahao XU-1/+171
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2025-03-13Rollup merge of #138162 - ehuss:library-2024, r=cuviperMatthias Krüger-1/+1
Update the standard library to Rust 2024 This updates the standard library to Rust 2024. This includes the following notable changes: - Macros are updated to use new expression fragment specifiers. This PR includes a test to illustrate the changes, primarily allowing `const {...}` expressions now. - Some tests show a change in MIR drop order. We do not believe this will be an observable change ([see zulip discussion](https://rust-lang.zulipchat.com/#narrow/channel/268952-edition/topic/standard.20library.20migration/near/500972873)). Fixes https://github.com/rust-lang/rust/issues/133081
2025-03-11Migrate std to Rust 2024Eric Huss-1/+1
2025-03-10Remove unused fileNicole L-4/+0
2025-03-10Format after patches have been appliedNicole LeGare-6/+11
2025-03-10Apply rustc-0054-Add-std-os-fd-support-for-Trusty.patchNicole LeGare-6/+43
2025-03-10Readd os::cygwin::raw as pub(crate)王宇逸-0/+5
2025-03-10Remove std::os::cygwin::raw王宇逸-91/+0
2025-03-10Fix building for cygwin王宇逸-0/+1
2025-03-10Initial STD support for Cygwin王宇逸-2/+207
Signed-off-by: Ookiineko <chiisaineko@protonmail.com>
2025-03-06library: Use size_of from the prelude instead of importedThalia Archibald-25/+17
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-02-28Use correct error message casing for `io::const_error`sNoratrieb-1/+1
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-17Remove std::os::wasi::fs::FileExt::tellThalia Archibald-11/+0
Following #137165 (Use `tell` for `<File as Seek>::stream_position`), `tell` is now directly exposed via `stream_position`, making `<File as FileExt>::tell` redundant. Remove it.
2025-02-14Add safe new to NotAllOnesKornel-24/+12
2025-02-12std: replace the `FromInner` implementation for addresses with private ↵joboet-2/+2
conversion functions Having these implementation available crate-wide means that platforms not using sockets for their networking code have to stub out the libc definitions required to support them. This PR moves the conversions to private helper functions that are only available where actually needed. I also fixed the signature of the function converting from a C socket address to a Rust one: taking a reference to a `sockaddr_storage` resulted in unsound usage inside `LookupHost::next`, which could create a reference to a structure smaller than `sockaddr_storage`. Thus I've replaced the argument type with a pointer and made the function `unsafe`.
2025-02-09Auto merge of #136751 - bjorn3:update_rustfmt, r=Mark-Simulacrumbors-34/+40
Update bootstrap compiler and rustfmt The rustfmt version we previously used formats things differently from what the latest nightly rustfmt does. This causes issues for subtrees that get formatted both in-tree and in their own repo. Updating the rustfmt used in-tree solves those issues. Also bumped the bootstrap compiler as the stage0 update command always updates both at the same time.