Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
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 b894521
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/node.cc
Expand Up @@ -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);
Expand Down
6 changes: 2 additions & 4 deletions src/node.js
Expand Up @@ -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);
Expand Down

0 comments on commit b894521

Please sign in to comment.