diff options
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/win32_os.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/lib/win32_os.rs b/src/lib/win32_os.rs index 65ee769fb5c..c502ebbfcb7 100644 --- a/src/lib/win32_os.rs +++ b/src/lib/win32_os.rs @@ -38,6 +38,7 @@ mod libc_constants { fn O_TRUNC() -> int { ret 512; } fn O_TEXT() -> int { ret 16384; } fn O_BINARY() -> int { ret 32768; } + fn O_NOINHERIT() -> int { ret 0x0080; } fn S_IRUSR() -> uint { ret 256u; // really _S_IREAD in win32 @@ -60,9 +61,18 @@ fn target_os() -> str { ret "win32"; } fn dylib_filename(base: str) -> str { ret base + ".dll"; } fn pipe() -> {in: int, out: int} { + // Windows pipes work subtly differently than unix pipes, and their + // inheritance has to be handled in a different way that I don't fully + // understand. Here we explicitly make the pipe non-inheritable, + // which means to pass it to a subprocess they need to be duplicated + // first, as in rust_run_program. let fds = {mutable in: 0, mutable out: 0}; - assert (os::libc::_pipe(ptr::addr_of(fds.in), 1024u, - libc_constants::O_BINARY()) == 0); + let res = os::libc::_pipe(ptr::addr_of(fds.in), 1024u, + libc_constants::O_BINARY() + | libc_constants::O_NOINHERIT()); + assert res == 0; + assert fds.in != -1 && fds.in != 0; + assert fds.out != -1 && fds.in != 0; ret {in: fds.in, out: fds.out}; } |
