src: move process.reallyExit impl into node_process_methods.cc

Because the part that is shared by `process.reallyExit` and the
Node.js teardown is `WaitForInspectorDisconnect()`, move that
into node_internals.h instead, and move the C++ binding code
into `node_process_methods.cc` since that's the only place
it's needed.

PR-URL: https://github.com/nodejs/node/pull/25860
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
This commit is contained in:
Joyee Cheung
2019-02-01 08:00:23 +08:00
committed by Daniel Bevenius
parent d3ea63921f
commit eb68619f95
3 changed files with 10 additions and 11 deletions

View File

@@ -118,7 +118,6 @@ using v8::Exception;
using v8::Function;
using v8::FunctionCallbackInfo;
using v8::HandleScope;
using v8::Int32;
using v8::Isolate;
using v8::Just;
using v8::Local;
@@ -158,7 +157,7 @@ struct V8Platform v8_platform;
static const unsigned kMaxSignal = 32;
#endif
static void WaitForInspectorDisconnect(Environment* env) {
void WaitForInspectorDisconnect(Environment* env) {
#if HAVE_INSPECTOR
if (env->inspector_agent()->IsActive()) {
// Restore signal dispositions, the app is done and is no longer
@@ -178,13 +177,6 @@ static void WaitForInspectorDisconnect(Environment* env) {
#endif
}
void Exit(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
WaitForInspectorDisconnect(env);
int code = args[0]->Int32Value(env->context()).FromMaybe(0);
env->Exit(code);
}
void SignalExit(int signo) {
uv_tty_reset_mode();
#ifdef __FreeBSD__

View File

@@ -86,7 +86,7 @@ void GetSockOrPeerName(const v8::FunctionCallbackInfo<v8::Value>& args) {
args.GetReturnValue().Set(err);
}
void Exit(const v8::FunctionCallbackInfo<v8::Value>& args);
void WaitForInspectorDisconnect(Environment* env);
void SignalExit(int signo);
#ifdef __POSIX__
void RegisterSignalHandler(int signal,

View File

@@ -385,6 +385,13 @@ static void DebugEnd(const FunctionCallbackInfo<Value>& args) {
#endif
}
static void ReallyExit(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
WaitForInspectorDisconnect(env);
int code = args[0]->Int32Value(env->context()).FromMaybe(0);
env->Exit(code);
}
static void InitializeProcessMethods(Local<Object> target,
Local<Value> unused,
Local<Context> context,
@@ -416,7 +423,7 @@ static void InitializeProcessMethods(Local<Object> target,
env->SetMethodNoSideEffect(target, "cwd", Cwd);
env->SetMethod(target, "dlopen", binding::DLOpen);
env->SetMethod(target, "reallyExit", Exit);
env->SetMethod(target, "reallyExit", ReallyExit);
env->SetMethodNoSideEffect(target, "uptime", Uptime);
}