std\sys\anonymous_pipe/
windows.rs1use crate::os::windows::io::FromRawHandle;
2use crate::sys::c;
3use crate::sys::handle::Handle;
4use crate::{io, ptr};
5
6pub type AnonPipe = Handle;
7
8pub fn pipe() -> io::Result<(AnonPipe, AnonPipe)> {
9 let mut read_pipe = c::INVALID_HANDLE_VALUE;
10 let mut write_pipe = c::INVALID_HANDLE_VALUE;
11
12 let ret = unsafe { c::CreatePipe(&mut read_pipe, &mut write_pipe, ptr::null_mut(), 0) };
13
14 if ret == 0 {
15 Err(io::Error::last_os_error())
16 } else {
17 unsafe { Ok((Handle::from_raw_handle(read_pipe), Handle::from_raw_handle(write_pipe))) }
18 }
19}