From b894521bd2ed81d3abfa3fc8931bd1b376a47b52 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 1 May 2012 13:53:30 -0700 Subject: [PATCH] process: ensure that "exit" doesn't get emitted twice on a natural exit Fixes "test/simple/test-process-exit.js". --- src/node.cc | 1 + src/node.js | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/node.cc b/src/node.cc index a593e79de..2cbd5c5cb 100644 --- a/src/node.cc +++ b/src/node.cc @@ -2772,6 +2772,7 @@ char** Init(int argc, char *argv[]) { void EmitExit(v8::Handle process_l) { // process.emit('exit') + process_l->Set(String::NewSymbol("_exiting"), True()); Local emit_v = process_l->Get(String::New("emit")); assert(emit_v->IsFunction()); Local emit = Local::Cast(emit_v); diff --git a/src/node.js b/src/node.js index 4da1f5a8f..bbda8c80c 100644 --- a/src/node.js +++ b/src/node.js @@ -409,11 +409,9 @@ }; startup.processKillAndExit = function() { - var exiting = false; - process.exit = function(code) { - if (!exiting) { - exiting = true; + if (!process._exiting) { + process._exiting = true; process.emit('exit', code || 0); } process.reallyExit(code || 0);