@@ -3096,22 +3096,6 @@ static void DispatchDebugMessagesAsyncCallback(uv_async_t* handle) {
30963096
30973097
30983098#ifdef __POSIX__
3099- static volatile sig_atomic_t caught_early_debug_signal;
3100-
3101-
3102- static void EarlyDebugSignalHandler (int signo) {
3103- caught_early_debug_signal = 1 ;
3104- }
3105-
3106-
3107- static void InstallEarlyDebugSignalHandler () {
3108- struct sigaction sa;
3109- memset (&sa, 0 , sizeof (sa));
3110- sa.sa_handler = EarlyDebugSignalHandler;
3111- sigaction (SIGUSR1, &sa, nullptr );
3112- }
3113-
3114-
31153099static void EnableDebugSignalHandler (int signo) {
31163100 // Call only async signal-safe functions here!
31173101 v8::Debug::DebugBreak (*static_cast <Isolate* volatile *>(&node_isolate));
@@ -3152,10 +3136,11 @@ void DebugProcess(const FunctionCallbackInfo<Value>& args) {
31523136static int RegisterDebugSignalHandler () {
31533137 // FIXME(bnoordhuis) Should be per-isolate or per-context, not global.
31543138 RegisterSignalHandler (SIGUSR1, EnableDebugSignalHandler);
3155- // If we caught a SIGUSR1 during the bootstrap process, re-raise it
3156- // now that the debugger infrastructure is in place.
3157- if (caught_early_debug_signal)
3158- raise (SIGUSR1);
3139+ // Unblock SIGUSR1. A pending SIGUSR1 signal will now be delivered.
3140+ sigset_t sigmask;
3141+ sigemptyset (&sigmask);
3142+ sigaddset (&sigmask, SIGUSR1);
3143+ CHECK_EQ (0 , pthread_sigmask (SIG_UNBLOCK, &sigmask, nullptr ));
31593144 return 0 ;
31603145}
31613146#endif // __POSIX__
@@ -3324,6 +3309,13 @@ static void DebugEnd(const FunctionCallbackInfo<Value>& args) {
33243309
33253310inline void PlatformInit () {
33263311#ifdef __POSIX__
3312+ sigset_t sigmask;
3313+ sigemptyset (&sigmask);
3314+ sigaddset (&sigmask, SIGUSR1);
3315+ CHECK_EQ (0 , pthread_sigmask (SIG_SETMASK, &sigmask, nullptr ));
3316+ RegisterSignalHandler (SIGPIPE, SIG_IGN);
3317+ RegisterSignalHandler (SIGINT, SignalExit, true );
3318+ RegisterSignalHandler (SIGTERM, SignalExit, true );
33273319 // Raise the open file descriptor limit.
33283320 struct rlimit lim;
33293321 if (getrlimit (RLIMIT_NOFILE, &lim) == 0 && lim.rlim_cur != lim.rlim_max ) {
@@ -3344,10 +3336,6 @@ inline void PlatformInit() {
33443336 }
33453337 } while (min + 1 < max);
33463338 }
3347- // Ignore SIGPIPE
3348- RegisterSignalHandler (SIGPIPE, SIG_IGN);
3349- RegisterSignalHandler (SIGINT, SignalExit, true );
3350- RegisterSignalHandler (SIGTERM, SignalExit, true );
33513339#endif // __POSIX__
33523340}
33533341
@@ -3618,11 +3606,6 @@ int Start(int argc, char** argv) {
36183606 if (replaceInvalid == nullptr )
36193607 WRITE_UTF8_FLAGS |= String::REPLACE_INVALID_UTF8;
36203608
3621- #if !defined(_WIN32)
3622- // Try hard not to lose SIGUSR1 signals during the bootstrap process.
3623- InstallEarlyDebugSignalHandler ();
3624- #endif
3625-
36263609 CHECK_GT (argc, 0 );
36273610
36283611 // Hack around with the argv pointer. Used for process.title = "blah".
0 commit comments