From 05882668f97c2533a5de757637033d36bcf93fac Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Thu, 18 Oct 2012 00:06:37 +0700 Subject: [PATCH] debugger: exit and kill child on SIGTERM or SIGHUP --- lib/_debugger.js | 7 ++++--- test/simple/test-debugger-repl-utf8.js | 3 ++- test/simple/test-debugger-repl.js | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/_debugger.js b/lib/_debugger.js index d719631358..19c26aa943 100644 --- a/lib/_debugger.js +++ b/lib/_debugger.js @@ -782,9 +782,10 @@ function Interface(stdin, stdout, args) { process.exit(0); }); - process.on('exit', function() { - self.killChild(); - }); + // Handle all possible exits + process.on('exit', this.killChild.bind(this)); + process.once('SIGTERM', process.exit.bind(process, 0)); + process.once('SIGHUP', process.exit.bind(process, 0)); var proto = Interface.prototype, ignored = ['pause', 'resume', 'exitRepl', 'handleBreak', diff --git a/test/simple/test-debugger-repl-utf8.js b/test/simple/test-debugger-repl-utf8.js index e141913605..720410de56 100644 --- a/test/simple/test-debugger-repl-utf8.js +++ b/test/simple/test-debugger-repl-utf8.js @@ -155,7 +155,8 @@ setTimeout(function() { err = err + '. Expected: ' + expected[0].lines.shift(); } quit(); - child.kill('SIGKILL'); + child.kill('SIGINT'); + child.kill('SIGTERM'); // give the sigkill time to work. setTimeout(function() { diff --git a/test/simple/test-debugger-repl.js b/test/simple/test-debugger-repl.js index 4d8d2b1d70..fb06441e7e 100644 --- a/test/simple/test-debugger-repl.js +++ b/test/simple/test-debugger-repl.js @@ -192,7 +192,8 @@ setTimeout(function() { err = err + '. Expected: ' + expected[0].lines.shift(); } quit(); - child.kill('SIGKILL'); + child.kill('SIGINT'); + child.kill('SIGTERM'); // give the sigkill time to work. setTimeout(function() {