about summary refs log tree commit diff
path: root/library/std/src/os
AgeCommit message (Collapse)AuthorLines
2022-10-20Make the whole `std::os::wasi::io` module stable.Dan Gohman-1/+1
2022-10-20Mark `std::os::wasi::io::AsFd` etc. as stable.Dan Gohman-1/+1
io_safety was stabilized in Rust 1.63, so mark the io_safety exports in `std::os::wasi::io` as stable. Fixes #103306.
2022-10-15Add `IsTerminal` trait to determine if a descriptor or handle is a terminalJosh Triplett-0/+34
The UNIX and WASI implementations use `isatty`. The Windows implementation uses the same logic the `atty` crate uses, including the hack needed to detect msys terminals. Implement this trait for `File` and for `Stdin`/`Stdout`/`Stderr` and their locked counterparts on all platforms. On UNIX and WASI, implement it for `BorrowedFd`/`OwnedFd`. On Windows, implement it for `BorrowedHandle`/`OwnedHandle`. Based on https://github.com/rust-lang/rust/pull/91121 Co-authored-by: Matt Wilkinson <mattwilki17@gmail.com>
2022-10-10Consolidate AsFd instances for stdio types into `library/std/src/os/fd/owned.rs`Josh Triplett-0/+52
2022-09-30Standard library OS support for Apple WatchOSVladimir Michael Eatwell-0/+235
2022-09-29Rollup merge of #98368 - sunfishcode:sunfishcode/std-os-fd, r=joshtriplettYuki Okushi-46/+26
Make `std::os::fd` public. `std::os::fd` defines types like `OwnedFd` and `RawFd` and is common between Unix and non-Unix platforms that share a basic file-descriptor concept. Rust currently uses this internally to simplify its own code, but it would be useful for external users in the same way, so make it public. This means that `OwnedFd` etc. will all appear in three places, for example on unix platforms: - `std::os::fd::OwnedFd` - `std::os::unix::io::OwnedFd` - `std::os::unix::prelude::OwnedFd` r? `````@joshtriplett`````
2022-09-12Rollup merge of #100767 - kadiwa4:escape_ascii, r=jackh726Dylan DPC-14/+2
Remove manual <[u8]>::escape_ascii `@rustbot` label: +C-cleanup
2022-09-04Don't duplicate file descriptors into stdio fdsbeetrees-1/+2
2022-09-02Fix compilation of the doc tests on Windows.Dan Gohman-0/+4
2022-08-29Re-introduce `unstable` attributes.Dan Gohman-2/+2
Add `#[unstable(feature = "os_fd", issue = "98699")]` to the new `pub use` declarations.
2022-08-29Clarify that the `fd` module is supported on Unix and WASI.Dan Gohman-3/+2
2022-08-29Make `std::os::fd` public.Dan Gohman-46/+23
`std::os::fd` defines types like `OwnedFd` and `RawFd` and is common between Unix and non-Unix platforms that share a basic file-descriptor concept. Rust currently uses this internally to simplify its own code, but it would be useful for external users in the same way, so make it public. This means that `OwnedFd` etc. will all appear in three places, for example on unix platforms: - `std::os::fd::OwnedFd` - `std::os::unix::io::OwnedFd` - `std::os::unix::prelude::OwnedFd`
2022-08-29Rollup merge of #96334 - devnexen:socket_mark, r=dtolnayMatthias Krüger-0/+50
socket `set_mark` addition. to be able to set a marker/id on the socket for network filtering (iptables/ipfw here) purpose.
2022-08-28Auto merge of #96324 - berendjan:set_tcp_quickack, r=dtolnaybors-0/+119
Add setter and getter for TCP_QUICKACK on TcpStream for Linux Reference issue #96256 Setting TCP_QUICKACK on TcpStream for Linux
2022-08-28Rollup merge of #100885 - mzohreva:mz/sgx-export-cancel-type, r=Mark-SimulacrumMatthias Krüger-1/+3
Export Cancel from std::os::fortanix_sgx::usercalls::raw This was missed in https://github.com/rust-lang/rust/pull/100642 cc ``@raoulstrackx`` and ``@jethrogb``
2022-08-23Rollup merge of #100835 - devnexen:listener_followups, r=devnexenDylan DPC-4/+2
net listen backlog update, follow-up from #97963. FreeBSD and using system limit instead for others.
2022-08-22Export Cancel from std::os::fortanix_sgx::usercalls::rawMohsen Zohrevandi-1/+3
This was missed in https://github.com/rust-lang/rust/pull/100642
2022-08-22net listen backlog update, follow-up from #97963.David CARLIER-4/+2
FreeBSD and using system limit instead for others.
2022-08-21Rollup merge of #100822 - WaffleLapkin:no_offset_question_mark, r=scottmcmMatthias Krüger-1/+1
Replace most uses of `pointer::offset` with `add` and `sub` As PR title says, it replaces `pointer::offset` in compiler and standard library with `pointer::add` and `pointer::sub`. This generally makes code cleaner, easier to grasp and removes (or, well, hides) integer casts. This is generally trivially correct, `.offset(-constant)` is just `.sub(constant)`, `.offset(usized as isize)` is just `.add(usized)`, etc. However in some cases we need to be careful with signs of things. r? ````@scottmcm```` _split off from #100746_
2022-08-21Replace most uses of `pointer::offset` with `add` and `sub`Maybe Waffle-1/+1
2022-08-20Auto merge of #100810 - matthiaskrgr:rollup-xep778s, r=matthiaskrgrbors-2/+10
Rollup of 9 pull requests Successful merges: - #97963 (net listen backlog set to negative on Linux.) - #99935 (Reenable disabled early syntax gates as future-incompatibility lints) - #100129 (add miri-test-libstd support to libstd) - #100500 (Ban references to `Self` in trait object substs for projection predicates too.) - #100636 (Revert "Revert "Allow dynamic linking for iOS/tvOS targets."") - #100718 ([rustdoc] Fix item info display) - #100769 (Suggest adding a reference to a trait assoc item) - #100777 (elaborate how revisions work with FileCheck stuff in src/test/codegen) - #100796 (Refactor: remove unnecessary string searchings) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-08-20Rollup merge of #97963 - devnexen:net_listener_neg, r=the8472Matthias Krüger-2/+10
net listen backlog set to negative on Linux. it will be 4076 (from 5.4) or 128.
2022-08-19use <[u8]>::escape_ascii instead of core::ascii::escape_defaultKaDiWa-14/+2
2022-08-16Update fortanix-sgx-abi and export some useful SGX usercall traitsMohsen Zohrevandi-0/+1
Update fortanix-sgx-abi to 0.5.0 to add support for cancel queue (see https://github.com/fortanix/rust-sgx/pull/405 and https://github.com/fortanix/rust-sgx/pull/404). Export some useful traits for processing SGX usercall. This is needed for https://github.com/fortanix/rust-sgx/pull/404 to avoid duplication.
2022-08-13created tcpstream quickack traitBerend-Jan Lange-0/+119
for linux and android
2022-08-12Adjust cfgsMark Rousskov-4/+4
2022-07-27Allow using stable os::fd::raw items through unstable os::wasi modulebstrie-0/+19
This fixes a regression from stable to nightly. Closes #99502.
2022-07-27Rollup merge of #98583 - joshtriplett:stabilize-windows-symlink-types, r=thomccYuki Okushi-5/+9
Stabilize Windows `FileTypeExt` with `is_symlink_dir` and `is_symlink_file` These calls allow detecting whether a symlink is a file or a directory, a distinction Windows maintains, and one important to software that wants to do further operations on the symlink (e.g. removing it).
2022-07-20Fix the stable version of `AsFd for Arc<T>` and `Box<T>`Josh Stone-2/+2
These merged in #97437 for 1.64.0, apart from the main `io_safety` feature that stabilized in 1.63.0.
2022-07-20Rollup merge of #98101 - vladimir-ea:stdlib_watch_os, r=thomccDylan DPC-4/+8
stdlib support for Apple WatchOS This is a follow-up to https://github.com/rust-lang/rust/pull/95243 (Add Apple WatchOS compiler targets) that adds stdlib support for Apple WatchOS. `@deg4uss3r` `@nagisa`
2022-07-20Library changes for Apple WatchOSVladimir Michael Eatwell-4/+8
2022-07-17Rollup merge of #99088 - niklasf:stabilize-process_set_process_group, ↵Yuki Okushi-3/+30
r=joshtriplett Document and stabilize process_set_process_group Tracking issue: https://github.com/rust-lang/rust/issues/93857 FCP finished here: https://github.com/rust-lang/rust/issues/93857#issuecomment-1179551697
2022-07-16Expand documentation for `process_group` Josh Triplett-1/+3
Explain PGID 0, and provide the acronym PGID.
2022-07-11Auto merge of #97841 - nvzqz:inline-encode-wide, r=thomccbors-0/+1
Inline Windows `OsStrExt::encode_wide` User crates currently produce much more code than necessary because the optimizer fails to make assumptions about this method.
2022-07-09Document and stabilize process_set_process_groupNiklas Fiekas-3/+28
Tracking issue: https://github.com/rust-lang/rust/issues/93857 FCP finished here: https://github.com/rust-lang/rust/issues/93857#issuecomment-1179551697
2022-07-07Rollup merge of #97917 - AronParker:master, r=ChrisDentonMatthias Krüger-0/+23
Implement ExitCodeExt for Windows Fixes #97914 ### Motivation: On Windows it is common for applications to return `HRESULT` (`i32`) or `DWORD` (`u32`) values. These stem from COM based components ([HRESULTS](https://docs.microsoft.com/en-us/windows/win32/api/objbase/nf-objbase-coinitialize)), Win32 errors ([GetLastError](https://docs.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-getlasterror)), GUI applications ([WM_QUIT](https://docs.microsoft.com/en-us/windows/win32/winmsg/wm-quit)) and more. The newly stabilized `ExitCode` provides an excellent fit for propagating these values, because `std::process::exit` does not run deconstructors which can result in errors. However, `ExitCode` currently only implements `From<u8> for ExitCode`, which disallows the full range of `i32`/`u32` values. This pull requests attempts to address that shortcoming by providing windows specific extensions that accept a `u32` value (which covers all possible `HRESULTS` and Win32 errors) analog to [ExitStatusExt::from_raw](https://doc.rust-lang.org/std/os/windows/process/trait.ExitStatusExt.html#tymethod.from_raw). This was also intended by the original Stabilization https://github.com/rust-lang/rust/pull/93840#issue-1129209143= as pointed out by ``@eggyal`` in https://github.com/rust-lang/rust/issues/97914#issuecomment-1151076755: > Issues around platform specific representations: We resolved this issue by changing the return type of report from i32 to the opaque type ExitCode. __That way we can change the underlying representation without affecting the API, letting us offer full support for platform specific exit code APIs in the future.__ [Emphasis added] ### API ```rust /// Windows-specific extensions to [`process::ExitCode`]. /// /// This trait is sealed: it cannot be implemented outside the standard library. /// This is so that future additional methods are not breaking changes. #[stable(feature = "windows_process_exit_code_from", since = "1.63.0")] pub trait ExitCodeExt: Sealed { /// Creates a new `ExitCode` from the raw underlying `u32` return value of /// a process. #[stable(feature = "windows_process_exit_code_from", since = "1.63.0")] fn from_raw(raw: u32) -> Self; } #[stable(feature = "windows_process_exit_code_from", since = "1.63.0")] impl ExitCodeExt for process::ExitCode { fn from_raw(raw: u32) -> Self { process::ExitCode::from_inner(From::from(raw)) } } ``` ### Misc I apologize in advance if I misplaced any attributes regarding stabilzation, as far as I learned traits are insta-stable so I chose to make them stable. If this is an error, please let me know and I'll correct it. I also added some additional machinery to make it work, analog to [ExitStatus](https://doc.rust-lang.org/std/process/struct.ExitStatus.html#). EDIT: Proposal: https://github.com/rust-lang/libs-team/issues/48
2022-07-07Fix doc build on unsupported osesDavid CARLIER-2/+16
2022-07-06changes from feedbackDavid Carlier-6/+4
2022-07-06doc additionsDavid Carlier-1/+33
2022-07-06socket `set_mark` addition.David Carlier-0/+6
to be able to set a marker/id on the socket for network filtering (iptables/ipfw here) purpose.
2022-07-06Fix typo in file descriptor docsFlorian Spieß-1/+1
2022-07-03Auto merge of #97437 - jyn514:impl-asrawfd-arc, r=dtolnaybors-0/+62
`impl<T: AsRawFd> AsRawFd for {Arc,Box}<T>` This allows implementing traits that require a raw FD on Arc and Box. Previously, you'd have to add the function to the trait itself: ```rust trait MyTrait { fn as_raw_fd(&self) -> RawFd; } impl<T: MyTrait> MyTrait for Arc<T> { fn as_raw_fd(&self) -> RawFd { (**self).as_raw_fd() } } ``` In particular, this leads to lots of "multiple applicable items in scope" errors because you have to disambiguate `MyTrait::as_raw_fd` from `AsRawFd::as_raw_fd` at each call site. In generic contexts, when passing the type to a function that takes `impl AsRawFd` it's also sometimes required to use `T: MyTrait + AsRawFd`, which wouldn't be necessary if I could write `MyTrait: AsRawFd`. After this PR, the code can be simpler: ```rust trait MyTrait: AsRawFd {} impl<T: MyTrait> MyTrait for Arc<T> {} ```
2022-06-27Seal Windows `FileTypeExt` extension trait to allow adding future methodsJosh Triplett-1/+5
2022-06-27Stabilize Windows `FileTypeExt` with `is_symlink_dir` and `is_symlink_file`Josh Triplett-4/+4
These calls allow detecting whether a symlink is a file or a directory, a distinction Windows maintains, and one important to software that wants to do further operations on the symlink (e.g. removing it).
2022-06-21`impl<T: AsFd> AsFd for {Arc,Box}<T>`Joshua Nelson-3/+33
2022-06-21`impl<T: AsRawFd> for {Arc,Box}<T>`Joshua Nelson-0/+32
This allows implementing traits that require a raw FD on Arc and Box. Previously, you'd have to add the function to the trait itself: ```rust trait MyTrait { fn as_raw_fd(&self) -> RawFd; } impl<T: MyTrait> MyTrait for Arc<T> { fn as_raw_fd(&self) -> RawFd { (**self).as_raw_fd() } } ```
2022-06-21update ioslice docs to use shared slicesConrad Ludgate-2/+2
2022-06-20Rollup merge of #97837 - sunfishcode:sunfishcode/proc-self-mem, r=m-ou-seDylan DPC-0/+19
Document Rust's stance on `/proc/self/mem` Add documentation to `std::os::unix::io` describing Rust's stance on `/proc/self/mem`, treating it as an external entity which is outside the scope of Rust's safety guarantees.
2022-06-20Rollup merge of #97149 - ChrisDenton:win_async_pipes, r=m-ou-seDylan DPC-0/+40
Windows: `CommandExt::async_pipes` Discussed in https://github.com/tokio-rs/tokio/issues/4670 was the need for third party crates to be able to force `process::Command::spawn` to create pipes as async. This implements the suggestion for a `async_pipes` method that gives third party crates that option. # Example: ```rust use std::process::{Command, Stdio}; Command::new("cmd") .async_pipes(true) .stdin(Stdio::piped()) .stdout(Stdio::piped()) .stderr(Stdio::piped()) .spawn() .unwrap(); ```
2022-06-20Windows: `CommandExt::async_pipes`Chris Denton-0/+40