From e899ecbf92572cd80f2b962e0387ab0a7ce98aac Mon Sep 17 00:00:00 2001 From: Johan Nordberg Date: Sun, 17 Aug 2014 13:22:01 +0200 Subject: [PATCH] Ignore SIGINT when processing stdin Fixes #126 --- bin/bunyan | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bin/bunyan b/bin/bunyan index 8b27a30..1807b37 100755 --- a/bin/bunyan +++ b/bin/bunyan @@ -99,6 +99,8 @@ var gOptsForUncaughtException; var pager = null; var stdout = process.stdout; +// Whether we are reading from stdin. +var readingStdin = false; //---- support functions @@ -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(); @@ -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;