]> git.lizzy.rs Git - rust.git/commit
native: Ignore stdio fds with /dev/null
authorAlex Crichton <alex@alexcrichton.com>
Tue, 27 May 2014 19:08:27 +0000 (12:08 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 28 May 2014 00:49:31 +0000 (17:49 -0700)
commit034eb4e724bf138bd2d90268cd0e759f99f0d396
tree5941c72b81bc4a09adcf0173d5d6a9c1b9895b5b
parent746d086f9322d24fa7b389dd911e204ca35012ae
native: Ignore stdio fds with /dev/null

When spawning a process, stdio file descriptors can be configured to be ignored,
which basically means that they'll be closed. Currently this is done by
literally closing the file descriptors in the child, but this can have adverse
side effects if the child process then opens a new file descriptor, assigning it
to a stdio number.

To work around the problems of the child, this commit alters the process
spawning code to map stdio fds to /dev/null on unix (and a similar equivalent on
windows) when they are specified as being ignored. This should allow spawned
programs to have more expected behavior when opening new files.

Closes #14456
src/liblibc/lib.rs
src/libnative/io/process.rs
src/test/run-pass/issue-14456.rs [new file with mode: 0644]