exit on EPIPE to avoid useless work

master
Trent Mick 2012-12-18 16:34:40 -08:00
parent c5bfdc4cf3
commit 74d3935348
2 changed files with 3 additions and 1 deletions

View File

@ -8,7 +8,8 @@ Known issues:
## bunyan 0.16.9 (not yet released)
(nothing yet)
- *Exit* on EPIPE, otherwise we sit there useless processing a huge log file
with, e.g. `bunyan huge.log | head`.
## bunyan 0.16.8

View File

@ -910,6 +910,7 @@ function emit(s) {
process.stdout.on("error", function (err) {
if (err.code === "EPIPE") {
// Pass. See <https://github.com/trentm/json/issues/9>.
drainStdoutAndExit(0);
} else {
warn(err);
drainStdoutAndExit(1);