summary refs log tree commit diff
path: root/library/std/src/os
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-04-29 03:06:45 +0000
committerbors <bors@rust-lang.org>2022-04-29 03:06:45 +0000
commitddb7fbe8434be481607ae199fe2aee976ee2fc2e (patch)
tree627e0d2da7fcaa67116ee3ec175754f900f1cae1 /library/std/src/os
parentbaaa3b682986879c7784b5733ecea942e9ae7de3 (diff)
parent1e7c15634d3b81b595d669382e45e6e136c730e1 (diff)
downloadrust-ddb7fbe8434be481607ae199fe2aee976ee2fc2e.tar.gz
rust-ddb7fbe8434be481607ae199fe2aee976ee2fc2e.zip
Auto merge of #96441 - ChrisDenton:sync-pipes, r=m-ou-se
Windows: Make stdin pipes synchronous

Stdin pipes do not need to be used asynchronously within the standard library. This is a first step in making pipes mostly synchronous.

r? `@m-ou-se`
Diffstat (limited to 'library/std/src/os')
-rw-r--r--library/std/src/os/windows/io/handle.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/library/std/src/os/windows/io/handle.rs b/library/std/src/os/windows/io/handle.rs
index e4de52612ef..f3d7be3f95c 100644
--- a/library/std/src/os/windows/io/handle.rs
+++ b/library/std/src/os/windows/io/handle.rs
@@ -198,6 +198,18 @@ impl OwnedHandle {
         })?;
         unsafe { Ok(Self::from_raw_handle(ret)) }
     }
+
+    /// Allow child processes to inherit the handle.
+    pub(crate) fn set_inheritable(&self) -> io::Result<()> {
+        cvt(unsafe {
+            c::SetHandleInformation(
+                self.as_raw_handle(),
+                c::HANDLE_FLAG_INHERIT,
+                c::HANDLE_FLAG_INHERIT,
+            )
+        })?;
+        Ok(())
+    }
 }
 
 impl TryFrom<HandleOrInvalid> for OwnedHandle {