@@ -275,7 +275,7 @@ pub struct Process {
275275
276276pub enum Stdio {
277277 Inherit ,
278- None ,
278+ Null ,
279279 Raw ( c_int ) ,
280280}
281281
@@ -416,7 +416,7 @@ impl Process {
416416 Stdio :: Raw ( fd. into_raw ( ) )
417417 } )
418418 }
419- s @ Stdio :: None |
419+ s @ Stdio :: Null |
420420 s @ Stdio :: Inherit |
421421 s @ Stdio :: Raw ( _) => Ok ( s) ,
422422 }
@@ -430,12 +430,10 @@ impl Process {
430430 Stdio :: Inherit => Ok ( ( ) ) ,
431431 Stdio :: Raw ( fd) => cvt_r ( || libc:: dup2 ( fd, dst) ) . map ( |_| ( ) ) ,
432432
433- // If a stdio file descriptor is set to be ignored, we open up
434- // /dev/null into that file descriptor. Otherwise, the first
435- // file descriptor opened up in the child would be numbered as
436- // one of the stdio file descriptors, which is likely to wreak
437- // havoc.
438- Stdio :: None => {
433+ // Open up a reference to /dev/null with appropriate read/write
434+ // permissions and then move it into the correct location via
435+ // `dup2`.
436+ Stdio :: Null => {
439437 let mut opts = OpenOptions :: new ( ) ;
440438 opts. read ( dst == libc:: STDIN_FILENO ) ;
441439 opts. write ( dst != libc:: STDIN_FILENO ) ;
@@ -590,7 +588,7 @@ mod tests {
590588
591589 let cat = t ! ( Process :: spawn( & cmd, Stdio :: Raw ( stdin_read. raw( ) ) ,
592590 Stdio :: Raw ( stdout_write. raw( ) ) ,
593- Stdio :: None ) ) ;
591+ Stdio :: Null ) ) ;
594592 drop ( stdin_read) ;
595593 drop ( stdout_write) ;
596594
0 commit comments