@ -3096,22 +3096,6 @@ static void DispatchDebugMessagesAsyncCallback(uv_async_t* handle) {
# ifdef __POSIX__
# ifdef __POSIX__
static volatile sig_atomic_t caught_early_debug_signal ;
static void EarlyDebugSignalHandler ( int signo ) {
caught_early_debug_signal = 1 ;
}
static void InstallEarlyDebugSignalHandler ( ) {
struct sigaction sa ;
memset ( & sa , 0 , sizeof ( sa ) ) ;
sa . sa_handler = EarlyDebugSignalHandler ;
sigaction ( SIGUSR1 , & sa , nullptr ) ;
}
static void EnableDebugSignalHandler ( int signo ) {
static void EnableDebugSignalHandler ( int signo ) {
// Call only async signal-safe functions here!
// Call only async signal-safe functions here!
v8 : : Debug : : DebugBreak ( * static_cast < Isolate * volatile * > ( & node_isolate ) ) ;
v8 : : Debug : : DebugBreak ( * static_cast < Isolate * volatile * > ( & node_isolate ) ) ;
@ -3152,10 +3136,11 @@ void DebugProcess(const FunctionCallbackInfo<Value>& args) {
static int RegisterDebugSignalHandler ( ) {
static int RegisterDebugSignalHandler ( ) {
// FIXME(bnoordhuis) Should be per-isolate or per-context, not global.
// FIXME(bnoordhuis) Should be per-isolate or per-context, not global.
RegisterSignalHandler ( SIGUSR1 , EnableDebugSignalHandler ) ;
RegisterSignalHandler ( SIGUSR1 , EnableDebugSignalHandler ) ;
// If we caught a SIGUSR1 during the bootstrap process, re-raise it
// Unblock SIGUSR1. A pending SIGUSR1 signal will now be delivered.
// now that the debugger infrastructure is in place.
sigset_t sigmask ;
if ( caught_early_debug_signal )
sigemptyset ( & sigmask ) ;
raise ( SIGUSR1 ) ;
sigaddset ( & sigmask , SIGUSR1 ) ;
CHECK_EQ ( 0 , pthread_sigmask ( SIG_UNBLOCK , & sigmask , nullptr ) ) ;
return 0 ;
return 0 ;
}
}
# endif // __POSIX__
# endif // __POSIX__
@ -3324,6 +3309,13 @@ static void DebugEnd(const FunctionCallbackInfo<Value>& args) {
inline void PlatformInit ( ) {
inline void PlatformInit ( ) {
# ifdef __POSIX__
# ifdef __POSIX__
sigset_t sigmask ;
sigemptyset ( & sigmask ) ;
sigaddset ( & sigmask , SIGUSR1 ) ;
CHECK_EQ ( 0 , pthread_sigmask ( SIG_SETMASK , & sigmask , nullptr ) ) ;
RegisterSignalHandler ( SIGPIPE , SIG_IGN ) ;
RegisterSignalHandler ( SIGINT , SignalExit , true ) ;
RegisterSignalHandler ( SIGTERM , SignalExit , true ) ;
// Raise the open file descriptor limit.
// Raise the open file descriptor limit.
struct rlimit lim ;
struct rlimit lim ;
if ( getrlimit ( RLIMIT_NOFILE , & lim ) = = 0 & & lim . rlim_cur ! = lim . rlim_max ) {
if ( getrlimit ( RLIMIT_NOFILE , & lim ) = = 0 & & lim . rlim_cur ! = lim . rlim_max ) {
@ -3344,10 +3336,6 @@ inline void PlatformInit() {
}
}
} while ( min + 1 < max ) ;
} while ( min + 1 < max ) ;
}
}
// Ignore SIGPIPE
RegisterSignalHandler ( SIGPIPE , SIG_IGN ) ;
RegisterSignalHandler ( SIGINT , SignalExit , true ) ;
RegisterSignalHandler ( SIGTERM , SignalExit , true ) ;
# endif // __POSIX__
# endif // __POSIX__
}
}
@ -3618,11 +3606,6 @@ int Start(int argc, char** argv) {
if ( replaceInvalid = = nullptr )
if ( replaceInvalid = = nullptr )
WRITE_UTF8_FLAGS | = String : : REPLACE_INVALID_UTF8 ;
WRITE_UTF8_FLAGS | = String : : REPLACE_INVALID_UTF8 ;
# if !defined(_WIN32)
// Try hard not to lose SIGUSR1 signals during the bootstrap process.
InstallEarlyDebugSignalHandler ( ) ;
# endif
CHECK_GT ( argc , 0 ) ;
CHECK_GT ( argc , 0 ) ;
// Hack around with the argv pointer. Used for process.title = "blah".
// Hack around with the argv pointer. Used for process.title = "blah".