about summary refs log tree commit diff
path: root/src/libstd/sys/unix
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2016-02-04 09:53:01 -0800
committerAlex Crichton <alex@alexcrichton.com>2016-02-10 09:28:48 -0800
commitb8bd8f3d7c9c8a3187d6c80ab201f66dedee457c (patch)
tree2bda921922e188b907e6b4eaa710446ad80fefab /src/libstd/sys/unix
parent627515a7ff4fe12084d7e95969bda307849b4d0e (diff)
downloadrust-b8bd8f3d7c9c8a3187d6c80ab201f66dedee457c.tar.gz
rust-b8bd8f3d7c9c8a3187d6c80ab201f66dedee457c.zip
std: Rename Stdio::None to Stdio::Null
This better reflects what it's actually doing as we don't actually have an
option for "leave this I/O slot as an empty hole".
Diffstat (limited to 'src/libstd/sys/unix')
-rw-r--r--src/libstd/sys/unix/process.rs16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/libstd/sys/unix/process.rs b/src/libstd/sys/unix/process.rs
index 41b9b3ef126..f776af29616 100644
--- a/src/libstd/sys/unix/process.rs
+++ b/src/libstd/sys/unix/process.rs
@@ -275,7 +275,7 @@ pub struct Process {
 
 pub enum Stdio {
     Inherit,
-    None,
+    Null,
     Raw(c_int),
 }
 
@@ -416,7 +416,7 @@ impl Process {
                         Stdio::Raw(fd.into_raw())
                     })
                 }
-                s @ Stdio::None |
+                s @ Stdio::Null |
                 s @ Stdio::Inherit |
                 s @ Stdio::Raw(_) => Ok(s),
             }
@@ -430,12 +430,10 @@ impl Process {
                 Stdio::Inherit => Ok(()),
                 Stdio::Raw(fd) => cvt_r(|| libc::dup2(fd, dst)).map(|_| ()),
 
-                // If a stdio file descriptor is set to be ignored, we open up
-                // /dev/null into that file descriptor. Otherwise, the first
-                // file descriptor opened up in the child would be numbered as
-                // one of the stdio file descriptors, which is likely to wreak
-                // havoc.
-                Stdio::None => {
+                // Open up a reference to /dev/null with appropriate read/write
+                // permissions and then move it into the correct location via
+                // `dup2`.
+                Stdio::Null => {
                     let mut opts = OpenOptions::new();
                     opts.read(dst == libc::STDIN_FILENO);
                     opts.write(dst != libc::STDIN_FILENO);
@@ -590,7 +588,7 @@ mod tests {
 
             let cat = t!(Process::spawn(&cmd, Stdio::Raw(stdin_read.raw()),
                                               Stdio::Raw(stdout_write.raw()),
-                                              Stdio::None));
+                                              Stdio::Null));
             drop(stdin_read);
             drop(stdout_write);