diff options
author | Nathan Rajlich <nathan@tootallnate.net> | 2012-05-01 13:53:30 -0700 |
---|---|---|
committer | Nathan Rajlich <nathan@tootallnate.net> | 2012-05-01 14:09:31 -0700 |
commit | b894521bd2ed81d3abfa3fc8931bd1b376a47b52 (patch) | |
tree | 7f9e83a681b74907cf2ff2bd551467266464ec85 /src | |
parent | 9f9c333cbc5cc142beb4afb98c27650d44824721 (diff) | |
download | node-b894521bd2ed81d3abfa3fc8931bd1b376a47b52.tar.gz |
process: ensure that "exit" doesn't get emitted twice on a natural exit
Fixes "test/simple/test-process-exit.js".
Diffstat (limited to 'src')
-rw-r--r-- | src/node.cc | 1 | ||||
-rw-r--r-- | 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<v8::Object> process_l) { // process.emit('exit') + process_l->Set(String::NewSymbol("_exiting"), True()); Local<Value> emit_v = process_l->Get(String::New("emit")); assert(emit_v->IsFunction()); Local<Function> emit = Local<Function>::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); |