File tree Expand file tree Collapse file tree 4 files changed +19
-3
lines changed
Expand file tree Collapse file tree 4 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -548,6 +548,18 @@ fn run_compiler_impl<'a>(args: &[String],
548548 ( result, Some ( sess) )
549549}
550550
551+ #[ cfg( unix) ]
552+ pub fn set_sigpipe_handler ( ) {
553+ unsafe {
554+ // Set the SIGPIPE signal handler, so that an EPIPE
555+ // will cause rustc to terminate, as expected.
556+ assert ! ( libc:: signal( libc:: SIGPIPE , libc:: SIG_DFL ) != libc:: SIG_ERR ) ;
557+ }
558+ }
559+
560+ #[ cfg( windows) ]
561+ pub fn set_sigpipe_handler ( ) { }
562+
551563// Extract output directory and file from matches.
552564fn make_output ( matches : & getopts:: Matches ) -> ( Option < PathBuf > , Option < PathBuf > ) {
553565 let odir = matches. opt_str ( "out-dir" ) . map ( |o| PathBuf :: from ( & o) ) ;
Original file line number Diff line number Diff line change @@ -101,6 +101,7 @@ struct Output {
101101
102102pub fn main ( ) {
103103 const STACK_SIZE : usize = 32_000_000 ; // 32MB
104+ rustc_driver:: set_sigpipe_handler ( ) ;
104105 env_logger:: init ( ) ;
105106 let res = std:: thread:: Builder :: new ( ) . stack_size ( STACK_SIZE ) . spawn ( move || {
106107 syntax:: with_globals ( move || {
Original file line number Diff line number Diff line change @@ -80,11 +80,11 @@ pub fn init() {
8080 reset_sigpipe ( ) ;
8181 }
8282
83- #[ cfg( not( any( target_os = "emscripten" , target_os= "fuchsia" ) ) ) ]
83+ #[ cfg( not( any( target_os = "emscripten" , target_os = "fuchsia" ) ) ) ]
8484 unsafe fn reset_sigpipe ( ) {
8585 assert ! ( signal( libc:: SIGPIPE , libc:: SIG_IGN ) != libc:: SIG_ERR ) ;
8686 }
87- #[ cfg( any( target_os = "emscripten" , target_os= "fuchsia" ) ) ]
87+ #[ cfg( any( target_os = "emscripten" , target_os = "fuchsia" ) ) ]
8888 unsafe fn reset_sigpipe ( ) { }
8989}
9090
Original file line number Diff line number Diff line change @@ -22,4 +22,7 @@ extern {}
2222
2323extern crate rustc_driver;
2424
25- fn main ( ) { rustc_driver:: main ( ) }
25+ fn main ( ) {
26+ rustc_driver:: set_sigpipe_handler ( ) ;
27+ rustc_driver:: main ( )
28+ }
You can’t perform that action at this time.
0 commit comments