Skip to content

Commit c47eb93

Browse files
joyeecheungtargos
authored andcommitted
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: #25860 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
1 parent d7ed125 commit c47eb93

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

src/node.cc

+1-9
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ using v8::Exception;
118118
using v8::Function;
119119
using v8::FunctionCallbackInfo;
120120
using v8::HandleScope;
121-
using v8::Int32;
122121
using v8::Isolate;
123122
using v8::Just;
124123
using v8::Local;
@@ -158,7 +157,7 @@ struct V8Platform v8_platform;
158157
static const unsigned kMaxSignal = 32;
159158
#endif
160159

161-
static void WaitForInspectorDisconnect(Environment* env) {
160+
void WaitForInspectorDisconnect(Environment* env) {
162161
#if HAVE_INSPECTOR
163162
if (env->inspector_agent()->IsActive()) {
164163
// Restore signal dispositions, the app is done and is no longer
@@ -178,13 +177,6 @@ static void WaitForInspectorDisconnect(Environment* env) {
178177
#endif
179178
}
180179

181-
void Exit(const FunctionCallbackInfo<Value>& args) {
182-
Environment* env = Environment::GetCurrent(args);
183-
WaitForInspectorDisconnect(env);
184-
int code = args[0]->Int32Value(env->context()).FromMaybe(0);
185-
env->Exit(code);
186-
}
187-
188180
void SignalExit(int signo) {
189181
uv_tty_reset_mode();
190182
#ifdef __FreeBSD__

src/node_internals.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void GetSockOrPeerName(const v8::FunctionCallbackInfo<v8::Value>& args) {
8686
args.GetReturnValue().Set(err);
8787
}
8888

89-
void Exit(const v8::FunctionCallbackInfo<v8::Value>& args);
89+
void WaitForInspectorDisconnect(Environment* env);
9090
void SignalExit(int signo);
9191
#ifdef __POSIX__
9292
void RegisterSignalHandler(int signal,

src/node_process_methods.cc

+8-1
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,13 @@ static void DebugEnd(const FunctionCallbackInfo<Value>& args) {
385385
#endif
386386
}
387387

388+
static void ReallyExit(const FunctionCallbackInfo<Value>& args) {
389+
Environment* env = Environment::GetCurrent(args);
390+
WaitForInspectorDisconnect(env);
391+
int code = args[0]->Int32Value(env->context()).FromMaybe(0);
392+
env->Exit(code);
393+
}
394+
388395
static void InitializeProcessMethods(Local<Object> target,
389396
Local<Value> unused,
390397
Local<Context> context,
@@ -416,7 +423,7 @@ static void InitializeProcessMethods(Local<Object> target,
416423

417424
env->SetMethodNoSideEffect(target, "cwd", Cwd);
418425
env->SetMethod(target, "dlopen", binding::DLOpen);
419-
env->SetMethod(target, "reallyExit", Exit);
426+
env->SetMethod(target, "reallyExit", ReallyExit);
420427
env->SetMethodNoSideEffect(target, "uptime", Uptime);
421428
}
422429

0 commit comments

Comments
 (0)