]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_driver/lib.rs
Rollup merge of #49606 - varkor:pipe-repair, r=alexcrichton
[rust.git] / src / librustc_driver / lib.rs
index 3dec84d174dd8d922badd5cd17625b8a14987639..cb91ff6a43e9ce08e0fd631a786b2455ba7b7b50 100644 (file)
@@ -547,6 +547,18 @@ macro_rules! do_or_return {($expr: expr, $sess: expr) => {
     (result, Some(sess))
 }
 
+#[cfg(unix)]
+pub fn set_sigpipe_handler() {
+    unsafe {
+        // Set the SIGPIPE signal handler, so that an EPIPE
+        // will cause rustc to terminate, as expected.
+        assert!(libc::signal(libc::SIGPIPE, libc::SIG_DFL) != libc::SIG_ERR);
+    }
+}
+
+#[cfg(windows)]
+pub fn set_sigpipe_handler() {}
+
 // Extract output directory and file from matches.
 fn make_output(matches: &getopts::Matches) -> (Option<PathBuf>, Option<PathBuf>) {
     let odir = matches.opt_str("out-dir").map(|o| PathBuf::from(&o));