Before this commit `RunAtExit` and `env->Dispose()` were never reached,
because `EmitExit` was always colling `exit`.
}
inline Environment::~Environment() {
+ v8::HandleScope handle_scope(isolate());
+
context()->SetAlignedPointerInEmbedderData(kContextEmbedderDataIndex, NULL);
#define V(PropertyName, TypeName) PropertyName ## _.Dispose();
ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES(V)
}
-void EmitExit(Environment* env) {
+int EmitExit(Environment* env) {
// process.emit('exit')
HandleScope handle_scope(env->isolate());
Context::Scope context_scope(env->context());
};
MakeCallback(env, process_object, "emit", ARRAY_SIZE(args), args);
- exit(code);
+ return code;
}
V8::SetEntropySource(crypto::EntropySource);
#endif
+ int code;
V8::Initialize();
{
Locker locker(node_isolate);
// be removed.
Context::Scope context_scope(env->context());
uv_run(env->event_loop(), UV_RUN_DEFAULT);
- EmitExit(env);
+ code = EmitExit(env);
RunAtExit(env);
env->Dispose();
env = NULL;
delete[] exec_argv;
exec_argv = NULL;
- return 0;
+ return code;
}