exit on EPIPE to avoid useless work

This commit is contained in:
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) ## 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 ## bunyan 0.16.8

View file

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