rust/library/std/src/sys/windows
bors e2d6aa77ed Auto merge of #98704 - vthib:impl-from-raw-for-childstd-structs, r=dtolnay
Implement From<OwnedFd/Handle> for ChildStdin/out/err object

## Summary

Comments in `library/std/src/process.rs` ( ab08639e59 ) indicates that `ChildStdin`, `ChildStdout`, `ChildStderr` implements some traits that are not actually implemented: `FromRawFd`, `FromRawHandle`, and the `From<OwnedFd>/From<OwnedHandle>` from the io_safety feature.

In this PR I implement `FromRawHandle` and `FromRawFd` for those 3 objects.

## Usecase

I have a usecase where those implementations are basically needed. I want to customize
in the `Command::spawn` API how the pipes for the parent/child communications are created (mainly to strengthen the security attributes on them). I can properly setup the pipes,
and the "child" handles can be provided to `Child::spawn` easily using `Stdio::from_raw_handle`. However, there is no way to generate the `ChildStd*` objects from the raw handle of the created name pipe, which would be very useful to still expose the same API
than in other OS (basically a `spawn(...) -> (Child, ChildStdin, ChildStdout, ChildSterr)`, where on windows this is customized), and to for example use `tokio::ChildStdin::from_std` afterwards.

## Questions

* Are those impls OK to add? I have searched to see if those impls were missing on purpose, or if it was just never implemented because never needed. I haven't found any indication on why they couldn't be added, although the user clearly has to be very careful that the handle provided makes sense (i think, mainly that it is in overlapped mode for windows).
* If this change is ok, adding the impls for the io_safety feature would probably be best, or should it be done in another PR?
* I just copy-pasted the `#[stable(...)]` attributes, but the `since` value has to be updated, I'm not sure to which value.
2023-09-28 09:59:03 +00:00
..
alloc Rework std::sys::windows::alloc 2021-03-26 12:38:26 +01:00
args Update Windows arg parsing tests 2021-08-08 22:11:29 +01:00
c Added option to set ProcThreadAttributes for Windows processes 2023-08-25 16:30:34 +02:00
handle Tests for unsound Windows file methods 2022-07-06 17:40:21 +01:00
locks std: remove lock wrappers in sys_common 2022-11-06 15:32:59 +01:00
os Replace AlignedAs with a more specific Align8 type 2022-08-30 01:15:59 -07:00
path Restore old behaviour on broken UNC paths 2022-09-03 07:56:38 +01:00
process Expose process main_thread_handle on Windows 2022-05-10 02:41:19 -03:00
stdio Fix bug in utf16_to_utf8 for zero length strings 2023-05-31 17:25:53 -07:00
thread_local_key Minor improvements to Windows TLS dtors 2023-07-20 23:27:24 +01:00
alloc.rs Explicitly link kernel32.lib from alloc 2022-09-10 11:57:36 +01:00
args.rs fix(std): Rename os_str_bytes to encoded_bytes 2023-09-01 19:33:16 -05:00
c.rs Revert "use c literals in library" 2023-07-05 13:11:26 +02:00
cmath.rs Add gamma and ln_gamma functions to f32 and f64 2023-07-31 07:41:50 -07:00
compat.rs remove additional [allow(unused_unsafe)] 2023-07-24 17:56:38 -04:00
env.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
fs.rs Add creation time support to FileTimes on apple and windows 2023-05-15 15:04:39 +01:00
handle.rs Use new bindings 2023-05-05 20:48:16 +01:00
io.rs Use new bindings 2023-05-05 20:48:16 +01:00
memchr.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
mod.rs Add a new helper to avoid calling io::Error::kind 2023-08-25 21:26:06 -04:00
net.rs Fix windows Socket::connect_timeout overflow 2023-06-18 01:56:11 +08:00
os.rs Usage zero as language id for FormatMessageW() 2023-08-19 14:32:15 +08:00
os_str.rs fix(std): Rename os_str_bytes to encoded_bytes 2023-09-01 19:33:16 -05:00
path.rs fix(std): Rename os_str_bytes to encoded_bytes 2023-09-01 19:33:16 -05:00
pipe.rs add FromOwnedFd/FromOwnedHandle for ChildStdin/out/err 2023-05-30 15:39:17 +02:00
process.rs Auto merge of #114590 - ijackson:stdio-stdio-2, r=dtolnay 2023-09-09 19:56:51 +00:00
rand.rs Lazy load ntdll functions on UWP 2023-06-10 16:34:20 +08:00
stack_overflow.rs Use new bindings 2023-05-05 20:48:16 +01:00
stack_overflow_uwp.rs Move all cleanup to sys::cleanup 2021-04-22 10:44:44 +02:00
stdio.rs Fix bug in utf16_to_utf8 for zero length strings 2023-05-31 17:25:53 -07:00
thread.rs Use new bindings 2023-05-05 20:48:16 +01:00
thread_local_dtor.rs Minor improvements to Windows TLS dtors 2023-07-20 23:27:24 +01:00
thread_local_key.rs Minor improvements to Windows TLS dtors 2023-07-20 23:27:24 +01:00
thread_parking.rs Replace libc::{type} with crate::ffi::{type} 2023-01-28 11:24:13 +05:30
time.rs Support setting file accessed/modified timestamps 2022-07-15 02:54:06 -07:00