From b89b0567427932fe37851a314610d795258f1834 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Tue, 26 Apr 2022 15:56:26 +0100 Subject: Add `set_inheritable` for Windows `Handle`s --- library/std/src/os/windows/io/handle.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'library/std/src/os/windows/io') diff --git a/library/std/src/os/windows/io/handle.rs b/library/std/src/os/windows/io/handle.rs index ee30cc8be6b..b41fb3395fe 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 for OwnedHandle { -- cgit 1.4.1-3-g733a5