From 18a00e1c8d89c072342673faa42f00068b55406c Mon Sep 17 00:00:00 2001 From: Abhay Jayant Kadam Date: Tue, 28 Jan 2014 00:53:11 +0530 Subject: [PATCH] check for broken pipe when streaming the output. For instance, if we give command: $rust | xargs -v we get, xargs: illegal option -- v usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements]] [-J replstr] [-L number] [-n number [-x]] [-P maxprocs] [-s size] [utility [argument ...]] error: internal compiler error: unexpected failure This message reflects a bug in the Rust compiler. We would appreciate a bug report: http://static.rust-lang.org/doc/master/complement-bugreport.html note: the compiler hit an unexpected failure path. this is a bug task '
' failed at 'Unhandled condition: io_error: io::IoError{kind: BrokenPipe, desc: "broken pipe", detail: None}', /Users/abhay/devel/rust/rust/src/ The BrokenPipe (or EPIPE) occurs when the receiving-end process returns non-zero exit-status. This patch checks if raised condition is not BrokenPipe, and if not, it raises the condition. --- src/libstd/io/stdio.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index f3f071ab78bff..7c4c95ba1c045 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -29,7 +29,7 @@ out.write(bytes!("Hello, world!")); use container::Container; use fmt; use io::{Reader, Writer, io_error, IoError, OtherIoError, - standard_error, EndOfFile, LineBufferedWriter}; + standard_error, EndOfFile, LineBufferedWriter, BrokenPipe}; use libc; use option::{Option, Some, None}; use prelude::drop; @@ -353,7 +353,13 @@ impl Writer for StdWriter { }; match ret { Ok(()) => {} - Err(e) => io_error::cond.raise(e) + Err(e) => { + // BrokenPipe (EPIPE) occurs when receiving process exits + // with error (i.e., non-zero) status + if e.kind != BrokenPipe { + io_error::cond.raise(e) + } + } } } }