@@ -188,6 +188,7 @@ static v8::Platform* default_platform;
188
188
189
189
#ifdef __POSIX__
190
190
static uv_sem_t debug_semaphore;
191
+ static const unsigned kMaxSignal = 32 ;
191
192
#endif
192
193
193
194
static void PrintErrorString (const char * format, ...) {
@@ -2149,7 +2150,29 @@ static void InitGroups(const FunctionCallbackInfo<Value>& args) {
2149
2150
#endif // __POSIX__ && !defined(__ANDROID__)
2150
2151
2151
2152
2153
+ static void WaitForInspectorDisconnect (Environment* env) {
2154
+ #if HAVE_INSPECTOR
2155
+ if (env->inspector_agent ()->IsConnected ()) {
2156
+ // Restore signal dispositions, the app is done and is no longer
2157
+ // capable of handling signals.
2158
+ #ifdef __POSIX__
2159
+ struct sigaction act;
2160
+ memset (&act, 0 , sizeof (act));
2161
+ for (unsigned nr = 1 ; nr < kMaxSignal ; nr += 1 ) {
2162
+ if (nr == SIGKILL || nr == SIGSTOP || nr == SIGPROF)
2163
+ continue ;
2164
+ act.sa_handler = (nr == SIGPIPE) ? SIG_IGN : SIG_DFL;
2165
+ CHECK_EQ (0 , sigaction (nr, &act, nullptr ));
2166
+ }
2167
+ #endif
2168
+ env->inspector_agent ()->WaitForDisconnect ();
2169
+ }
2170
+ #endif
2171
+ }
2172
+
2173
+
2152
2174
void Exit (const FunctionCallbackInfo<Value>& args) {
2175
+ WaitForInspectorDisconnect (Environment::GetCurrent (args));
2153
2176
exit (args[0 ]->Int32Value ());
2154
2177
}
2155
2178
@@ -4076,7 +4099,7 @@ inline void PlatformInit() {
4076
4099
// The hard-coded upper limit is because NSIG is not very reliable; on Linux,
4077
4100
// it evaluates to 32, 34 or 64, depending on whether RT signals are enabled.
4078
4101
// Counting up to SIGRTMIN doesn't work for the same reason.
4079
- for (unsigned nr = 1 ; nr < 32 ; nr += 1 ) {
4102
+ for (unsigned nr = 1 ; nr < kMaxSignal ; nr += 1 ) {
4080
4103
if (nr == SIGKILL || nr == SIGSTOP)
4081
4104
continue ;
4082
4105
act.sa_handler = (nr == SIGPIPE) ? SIG_IGN : SIG_DFL;
@@ -4470,24 +4493,7 @@ static void StartNodeInstance(void* arg) {
4470
4493
instance_data->set_exit_code (exit_code);
4471
4494
RunAtExit (env);
4472
4495
4473
- #if HAVE_INSPECTOR
4474
- if (env->inspector_agent ()->IsConnected ()) {
4475
- // Restore signal dispositions, the app is done and is no longer
4476
- // capable of handling signals.
4477
- #ifdef __POSIX__
4478
- struct sigaction act;
4479
- memset (&act, 0 , sizeof (act));
4480
- for (unsigned nr = 1 ; nr < 32 ; nr += 1 ) {
4481
- if (nr == SIGKILL || nr == SIGSTOP || nr == SIGPROF)
4482
- continue ;
4483
- act.sa_handler = (nr == SIGPIPE) ? SIG_IGN : SIG_DFL;
4484
- CHECK_EQ (0 , sigaction (nr, &act, nullptr ));
4485
- }
4486
- #endif
4487
- env->inspector_agent ()->WaitForDisconnect ();
4488
- }
4489
- #endif
4490
-
4496
+ WaitForInspectorDisconnect (env);
4491
4497
#if defined(LEAK_SANITIZER)
4492
4498
__lsan_do_leak_check ();
4493
4499
#endif
0 commit comments