diff options
Diffstat (limited to 'library/std')
| -rw-r--r-- | library/std/src/os/windows/io/handle.rs | 12 | ||||
| -rw-r--r-- | library/std/src/sys/windows/handle.rs | 4 |
2 files changed, 16 insertions, 0 deletions
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<HandleOrInvalid> for OwnedHandle { diff --git a/library/std/src/sys/windows/handle.rs b/library/std/src/sys/windows/handle.rs index ef9a8bd6900..3b609825a79 100644 --- a/library/std/src/sys/windows/handle.rs +++ b/library/std/src/sys/windows/handle.rs @@ -221,6 +221,10 @@ impl Handle { Ok(Self(self.0.duplicate(access, inherit, options)?)) } + pub(crate) fn set_inheritable(&self) -> io::Result<()> { + self.0.set_inheritable() + } + /// Performs a synchronous read. /// /// If the handle is opened for asynchronous I/O then this abort the process. |
