|
|
@ -188,6 +188,7 @@ static v8::Platform* default_platform; |
|
|
|
|
|
|
|
#ifdef __POSIX__ |
|
|
|
static uv_sem_t debug_semaphore; |
|
|
|
static const unsigned kMaxSignal = 32; |
|
|
|
#endif |
|
|
|
|
|
|
|
static void PrintErrorString(const char* format, ...) { |
|
|
@ -2149,7 +2150,29 @@ static void InitGroups(const FunctionCallbackInfo<Value>& args) { |
|
|
|
#endif // __POSIX__ && !defined(__ANDROID__)
|
|
|
|
|
|
|
|
|
|
|
|
static void WaitForInspectorDisconnect(Environment* env) { |
|
|
|
#if HAVE_INSPECTOR |
|
|
|
if (env->inspector_agent()->IsConnected()) { |
|
|
|
// Restore signal dispositions, the app is done and is no longer
|
|
|
|
// capable of handling signals.
|
|
|
|
#ifdef __POSIX__ |
|
|
|
struct sigaction act; |
|
|
|
memset(&act, 0, sizeof(act)); |
|
|
|
for (unsigned nr = 1; nr < kMaxSignal; nr += 1) { |
|
|
|
if (nr == SIGKILL || nr == SIGSTOP || nr == SIGPROF) |
|
|
|
continue; |
|
|
|
act.sa_handler = (nr == SIGPIPE) ? SIG_IGN : SIG_DFL; |
|
|
|
CHECK_EQ(0, sigaction(nr, &act, nullptr)); |
|
|
|
} |
|
|
|
#endif |
|
|
|
env->inspector_agent()->WaitForDisconnect(); |
|
|
|
} |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Exit(const FunctionCallbackInfo<Value>& args) { |
|
|
|
WaitForInspectorDisconnect(Environment::GetCurrent(args)); |
|
|
|
exit(args[0]->Int32Value()); |
|
|
|
} |
|
|
|
|
|
|
@ -4076,7 +4099,7 @@ inline void PlatformInit() { |
|
|
|
// The hard-coded upper limit is because NSIG is not very reliable; on Linux,
|
|
|
|
// it evaluates to 32, 34 or 64, depending on whether RT signals are enabled.
|
|
|
|
// Counting up to SIGRTMIN doesn't work for the same reason.
|
|
|
|
for (unsigned nr = 1; nr < 32; nr += 1) { |
|
|
|
for (unsigned nr = 1; nr < kMaxSignal; nr += 1) { |
|
|
|
if (nr == SIGKILL || nr == SIGSTOP) |
|
|
|
continue; |
|
|
|
act.sa_handler = (nr == SIGPIPE) ? SIG_IGN : SIG_DFL; |
|
|
@ -4470,24 +4493,7 @@ static void StartNodeInstance(void* arg) { |
|
|
|
instance_data->set_exit_code(exit_code); |
|
|
|
RunAtExit(env); |
|
|
|
|
|
|
|
#if HAVE_INSPECTOR |
|
|
|
if (env->inspector_agent()->IsConnected()) { |
|
|
|
// Restore signal dispositions, the app is done and is no longer
|
|
|
|
// capable of handling signals.
|
|
|
|
#ifdef __POSIX__ |
|
|
|
struct sigaction act; |
|
|
|
memset(&act, 0, sizeof(act)); |
|
|
|
for (unsigned nr = 1; nr < 32; nr += 1) { |
|
|
|
if (nr == SIGKILL || nr == SIGSTOP || nr == SIGPROF) |
|
|
|
continue; |
|
|
|
act.sa_handler = (nr == SIGPIPE) ? SIG_IGN : SIG_DFL; |
|
|
|
CHECK_EQ(0, sigaction(nr, &act, nullptr)); |
|
|
|
} |
|
|
|
#endif |
|
|
|
env->inspector_agent()->WaitForDisconnect(); |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
WaitForInspectorDisconnect(env); |
|
|
|
#if defined(LEAK_SANITIZER) |
|
|
|
__lsan_do_leak_check(); |
|
|
|
#endif |
|
|
|