fix(bin): don't ignore SIGINT

Ignoring SIGINT can make the process interminable. The emitting node process should instead ignore EPIPE.

Reverts #161, Fixes #246
This commit is contained in:
Zach Bjornson 2016-05-24 18:27:45 -07:00 committed by Trent Mick
parent f4fff7b7fa
commit aff022bb2e

View file

@ -118,9 +118,6 @@ var gUsingConditionOpts = false;
var pager = null; var pager = null;
var stdout = process.stdout; var stdout = process.stdout;
// Whether we are reading from stdin.
var readingStdin = false;
//---- support functions //---- support functions
@ -1133,7 +1130,6 @@ function drainStdoutAndExit(code) {
* @param callback {Function} `function ()` * @param callback {Function} `function ()`
*/ */
function processStdin(opts, stylize, callback) { function processStdin(opts, stylize, callback) {
readingStdin = true;
var leftover = ''; // Left-over partial line from last chunk. var leftover = ''; // Left-over partial line from last chunk.
var stdin = process.stdin; var stdin = process.stdin;
stdin.resume(); stdin.resume();
@ -1469,16 +1465,7 @@ function cleanupAndExit(code, signal) {
//---- mainline //---- mainline
process.on('SIGINT', function () { process.on('SIGINT', function () { cleanupAndExit(1, 'SIGINT'); });
/**
* 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('SIGQUIT', function () { cleanupAndExit(1, 'SIGQUIT'); }); process.on('SIGQUIT', function () { cleanupAndExit(1, 'SIGQUIT'); });
process.on('SIGTERM', function () { cleanupAndExit(1, 'SIGTERM'); }); process.on('SIGTERM', function () { cleanupAndExit(1, 'SIGTERM'); });
process.on('SIGHUP', function () { cleanupAndExit(1, 'SIGHUP'); }); process.on('SIGHUP', function () { cleanupAndExit(1, 'SIGHUP'); });