@@ -187,6 +187,7 @@ static v8::Platform* default_platform;
187
187
188
188
#ifdef __POSIX__
189
189
static uv_sem_t debug_semaphore;
190
+ static const unsigned kMaxSignal = 32 ;
190
191
#endif
191
192
192
193
static void PrintErrorString (const char * format, ...) {
@@ -2095,7 +2096,29 @@ static void InitGroups(const FunctionCallbackInfo<Value>& args) {
2095
2096
#endif // __POSIX__ && !defined(__ANDROID__)
2096
2097
2097
2098
2099
+ static void WaitForInspectorDisconnect (Environment* env) {
2100
+ #if HAVE_INSPECTOR
2101
+ if (env->inspector_agent ()->IsConnected ()) {
2102
+ // Restore signal dispositions, the app is done and is no longer
2103
+ // capable of handling signals.
2104
+ #ifdef __POSIX__
2105
+ struct sigaction act;
2106
+ memset (&act, 0 , sizeof (act));
2107
+ for (unsigned nr = 1 ; nr < kMaxSignal ; nr += 1 ) {
2108
+ if (nr == SIGKILL || nr == SIGSTOP || nr == SIGPROF)
2109
+ continue ;
2110
+ act.sa_handler = (nr == SIGPIPE) ? SIG_IGN : SIG_DFL;
2111
+ CHECK_EQ (0 , sigaction (nr, &act, nullptr ));
2112
+ }
2113
+ #endif
2114
+ env->inspector_agent ()->WaitForDisconnect ();
2115
+ }
2116
+ #endif
2117
+ }
2118
+
2119
+
2098
2120
void Exit (const FunctionCallbackInfo<Value>& args) {
2121
+ WaitForInspectorDisconnect (Environment::GetCurrent (args));
2099
2122
exit (args[0 ]->Int32Value ());
2100
2123
}
2101
2124
@@ -3992,7 +4015,7 @@ inline void PlatformInit() {
3992
4015
// The hard-coded upper limit is because NSIG is not very reliable; on Linux,
3993
4016
// it evaluates to 32, 34 or 64, depending on whether RT signals are enabled.
3994
4017
// Counting up to SIGRTMIN doesn't work for the same reason.
3995
- for (unsigned nr = 1 ; nr < 32 ; nr += 1 ) {
4018
+ for (unsigned nr = 1 ; nr < kMaxSignal ; nr += 1 ) {
3996
4019
if (nr == SIGKILL || nr == SIGSTOP)
3997
4020
continue ;
3998
4021
act.sa_handler = (nr == SIGPIPE) ? SIG_IGN : SIG_DFL;
@@ -4302,24 +4325,7 @@ static void StartNodeInstance(void* arg) {
4302
4325
instance_data->set_exit_code (exit_code);
4303
4326
RunAtExit (&env);
4304
4327
4305
- #if HAVE_INSPECTOR
4306
- if (env.inspector_agent ()->IsConnected ()) {
4307
- // Restore signal dispositions, the app is done and is no longer
4308
- // capable of handling signals.
4309
- #ifdef __POSIX__
4310
- struct sigaction act;
4311
- memset (&act, 0 , sizeof (act));
4312
- for (unsigned nr = 1 ; nr < 32 ; nr += 1 ) {
4313
- if (nr == SIGKILL || nr == SIGSTOP || nr == SIGPROF)
4314
- continue ;
4315
- act.sa_handler = (nr == SIGPIPE) ? SIG_IGN : SIG_DFL;
4316
- CHECK_EQ (0 , sigaction (nr, &act, nullptr ));
4317
- }
4318
- #endif
4319
- env.inspector_agent ()->WaitForDisconnect ();
4320
- }
4321
- #endif
4322
-
4328
+ WaitForInspectorDisconnect (&env);
4323
4329
#if defined(LEAK_SANITIZER)
4324
4330
__lsan_do_leak_check ();
4325
4331
#endif
0 commit comments