Skip to content

Commit

Permalink
fix(bin): don't ignore SIGINT
Browse files Browse the repository at this point in the history
Ignoring SIGINT can make the process interminable. The emitting node process should instead ignore EPIPE.

Reverts #161, Fixes #246
  • Loading branch information
zbjornson authored and trentm committed Mar 21, 2017
1 parent f4fff7b commit aff022b
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions bin/bunyan
Expand Up @@ -118,9 +118,6 @@ var gUsingConditionOpts = false;
var pager = null;
var stdout = process.stdout;

// Whether we are reading from stdin.
var readingStdin = false;



//---- support functions
Expand Down Expand Up @@ -1133,7 +1130,6 @@ function drainStdoutAndExit(code) {
* @param callback {Function} `function ()`
*/
function processStdin(opts, stylize, callback) {
readingStdin = true;
var leftover = ''; // Left-over partial line from last chunk.
var stdin = process.stdin;
stdin.resume();
Expand Down Expand Up @@ -1469,16 +1465,7 @@ function cleanupAndExit(code, signal) {

//---- mainline

process.on('SIGINT', function () {
/**
* Ignore SIGINT (Ctrl+C) if processing stdin -- we should process
* remaining output from preceding process in the pipeline and
* except *it* to close.
*/
if (!readingStdin) {
cleanupAndExit(1, 'SIGINT');
}
});
process.on('SIGINT', function () { cleanupAndExit(1, 'SIGINT'); });
process.on('SIGQUIT', function () { cleanupAndExit(1, 'SIGQUIT'); });
process.on('SIGTERM', function () { cleanupAndExit(1, 'SIGTERM'); });
process.on('SIGHUP', function () { cleanupAndExit(1, 'SIGHUP'); });
Expand Down

0 comments on commit aff022b

Please sign in to comment.