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

Fixes "test/simple/test-process-exit.js".
This commit is contained in:
Nathan Rajlich
2012-05-01 13:53:30 -07:00
parent 9f9c333cbc
commit b894521bd2
2 changed files with 3 additions and 4 deletions

View File

@@ -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 File

@@ -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);