mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
core: Use a uv_signal for debug listener
Starting the debugger directly in the SIGUSR1 signal handler results in a malloc lock contention ~1% of the time. It hangs the test, which is annoying on a daily basis to all of us, but it also is pretty terrible if you actually want to debug a node process that has gone sideways. Credit to @bnoordhuis for most of this. I just added the unref which keeps it from messing up the event loop for other stuff.
This commit is contained in:
parent
7bc449c063
commit
30e5366b29
@ -2715,7 +2715,7 @@ static void EnableDebug(bool wait_connect) {
|
||||
|
||||
|
||||
#ifdef __POSIX__
|
||||
static void EnableDebugSignalHandler(int signal) {
|
||||
static void EnableDebugSignalHandler(uv_signal_t* handle, int) {
|
||||
// Break once process will return execution to v8
|
||||
v8::Debug::DebugBreak(node_isolate);
|
||||
|
||||
@ -2997,7 +2997,10 @@ char** Init(int argc, char *argv[]) {
|
||||
#ifdef _WIN32
|
||||
RegisterDebugSignalHandler();
|
||||
#else // Posix
|
||||
RegisterSignalHandler(SIGUSR1, EnableDebugSignalHandler);
|
||||
static uv_signal_t signal_watcher;
|
||||
uv_signal_init(uv_default_loop(), &signal_watcher);
|
||||
uv_signal_start(&signal_watcher, EnableDebugSignalHandler, SIGUSR1);
|
||||
uv_unref((uv_handle_t*)&signal_watcher);
|
||||
#endif // __POSIX__
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user