File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change 99// Make sure that these behaviors don't get inherited to children 
1010// spawned via std::process, since they're needed for traditional UNIX 
1111// filter behavior. 
12- // This test checks that `while echo y ; do : ; done | head` terminates  
13- // (instead of running forever), and that it does not print an error  
14- // message about a broken pipe. 
12+ // This test checks that `yes` or ` while echo y ; do : ; done | head` 
13+ // terminates  (instead of running forever), and that it does not print an 
14+ // error  message about a broken pipe. 
1515
1616//@ ignore-vxworks no 'sh' 
1717//@ ignore-fuchsia no 'sh' 
@@ -22,14 +22,21 @@ use std::process;
2222use  std:: thread; 
2323
2424fn  main ( )  { 
25-     // Just in case `yes` doesn't check for EPIPE... 
25+     // Just in case `yes` or `while-echo`  doesn't check for EPIPE... 
2626    thread:: spawn ( || { 
2727        thread:: sleep_ms ( 5000 ) ; 
2828        process:: exit ( 1 ) ; 
2929    } ) ; 
30+     // QNX Neutrino does not have `yes`. Therefore, use `while-echo` for `nto` 
31+     // and `yes` for other platforms. 
32+     let  command = if  cfg ! ( target_os = "nto" )  { 
33+         "while echo y ; do : ; done | head" 
34+     }  else  { 
35+         "yes | head" 
36+     } ; 
3037    let  output = process:: Command :: new ( "sh" ) 
3138        . arg ( "-c" ) 
32-         . arg ( "while echo y ; do : ; done | head" ) 
39+         . arg ( command ) 
3340        . output ( ) 
3441        . unwrap ( ) ; 
3542    assert ! ( output. status. success( ) ) ; 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments