Skip to content

Commit

Permalink
Merge pull request #161 from jnordberg/ignore-sigint
Browse files Browse the repository at this point in the history
Ignore SIGINT when processing stdin
  • Loading branch information
trentm committed Aug 25, 2014
2 parents 26a8bb0 + e899ecb commit 96b9f35
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions bin/bunyan
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ var gOptsForUncaughtException;
var pager = null;
var stdout = process.stdout;

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


//---- support functions
Expand Down Expand Up @@ -1050,6 +1052,7 @@ 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 @@ -1349,6 +1352,10 @@ function asyncForEach(arr, iterator, callback) {
*/
var cleanedUp = false;
function cleanupAndExit(code, signal) {
// Do not exit if reading form stdin and we get a SIGINT (ctrl-c)
if (readingStdin && signal === 'SIGINT') {
return;
}
// Guard one call.
if (cleanedUp) {
return;
Expand Down

0 comments on commit 96b9f35

Please sign in to comment.