File tree 4 files changed +19
-3
lines changed
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],
548
548
( result, Some ( sess) )
549
549
}
550
550
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
+
551
563
// Extract output directory and file from matches.
552
564
fn make_output ( matches : & getopts:: Matches ) -> ( Option < PathBuf > , Option < PathBuf > ) {
553
565
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 {
101
101
102
102
pub fn main ( ) {
103
103
const STACK_SIZE : usize = 32_000_000 ; // 32MB
104
+ rustc_driver:: set_sigpipe_handler ( ) ;
104
105
env_logger:: init ( ) ;
105
106
let res = std:: thread:: Builder :: new ( ) . stack_size ( STACK_SIZE ) . spawn ( move || {
106
107
syntax:: with_globals ( move || {
Original file line number Diff line number Diff line change @@ -80,11 +80,11 @@ pub fn init() {
80
80
reset_sigpipe ( ) ;
81
81
}
82
82
83
- #[ cfg( not( any( target_os = "emscripten" , target_os= "fuchsia" ) ) ) ]
83
+ #[ cfg( not( any( target_os = "emscripten" , target_os = "fuchsia" ) ) ) ]
84
84
unsafe fn reset_sigpipe ( ) {
85
85
assert ! ( signal( libc:: SIGPIPE , libc:: SIG_IGN ) != libc:: SIG_ERR ) ;
86
86
}
87
- #[ cfg( any( target_os = "emscripten" , target_os= "fuchsia" ) ) ]
87
+ #[ cfg( any( target_os = "emscripten" , target_os = "fuchsia" ) ) ]
88
88
unsafe fn reset_sigpipe ( ) { }
89
89
}
90
90
Original file line number Diff line number Diff line change @@ -22,4 +22,7 @@ extern {}
22
22
23
23
extern crate rustc_driver;
24
24
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