Skip to content

Commit

Permalink
src: move process.reallyExit impl into node_process_methods.cc
Browse files Browse the repository at this point in the history
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: #25860
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Minwoo Jung <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
  • Loading branch information
joyeecheung authored and targos committed Feb 10, 2019
1 parent d7ed125 commit c47eb93
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
10 changes: 1 addition & 9 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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__
Expand Down
2 changes: 1 addition & 1 deletion src/node_internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 8 additions & 1 deletion src/node_process_methods.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit c47eb93

Please sign in to comment.