Permalink
Browse files

process: ensure that "exit" doesn't get emitted twice on a natural exit

Fixes "test/simple/test-process-exit.js".
  • Loading branch information...
TooTallNate committed May 1, 2012
1 parent 9f9c333 commit b894521bd2ed81d3abfa3fc8931bd1b376a47b52
Showing with 3 additions and 4 deletions.
  1. +1 −0 src/node.cc
  2. +2 −4 src/node.js
View
@@ -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);
View
@@ -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);

0 comments on commit b894521

Please sign in to comment.