mirror of
https://github.com/nodejs/node-v0.x-archive.git
synced 2026-04-28 03:01:10 -04:00
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:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user