From 2e44af7702f9daf314ffd41f9e9fc8ec082c598a Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Tue, 21 May 2019 00:11:12 -0700 Subject: [PATCH] filedescriptor: pipes should not be inheritable on windows --- filedescriptor/src/windows.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/filedescriptor/src/windows.rs b/filedescriptor/src/windows.rs index 35ab991d8..2083e161b 100644 --- a/filedescriptor/src/windows.rs +++ b/filedescriptor/src/windows.rs @@ -8,6 +8,7 @@ use std::os::windows::prelude::*; use std::ptr; use winapi::um::fileapi::*; use winapi::um::handleapi::*; +use winapi::um::minwinbase::SECURITY_ATTRIBUTES; use winapi::um::namedpipeapi::CreatePipe; use winapi::um::processthreadsapi::*; use winapi::um::winnt::HANDLE; @@ -171,9 +172,14 @@ impl io::Write for FileDescriptor { impl Pipe { pub fn new() -> Fallible { + let mut sa = SECURITY_ATTRIBUTES { + nLength: std::mem::size_of::() as u32, + lpSecurityDescriptor: ptr::null_mut(), + bInheritHandle: 0, + }; let mut read: HANDLE = INVALID_HANDLE_VALUE as _; let mut write: HANDLE = INVALID_HANDLE_VALUE as _; - if unsafe { CreatePipe(&mut read, &mut write, ptr::null_mut(), 0) } == 0 { + if unsafe { CreatePipe(&mut read, &mut write, &mut sa, 0) } == 0 { bail!("CreatePipe failed: {}", IoError::last_os_error()); } Ok(Pipe {