GeezerVison is showing github.com — src: call unmask after install signal handler · nodejs/node@55838e7
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: src/inspector_agent.cc +5-4Lines changed: 5 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -123,12 +123,11 @@ static int StartDebugSignalHandler() { | 123 | 123 | CHECK_EQ(0, pthread_sigmask(SIG_SETMASK, &sigmask, &savemask)); | 124 | 124 | sigmask = savemask; | 125 | 125 | pthread_t thread; | 126 | | - const int err = pthread_create(&thread, &attr, | 127 | | - StartIoThreadMain, nullptr); | 128 | | - // Restore original mask | 129 | | - CHECK_EQ(0, pthread_sigmask(SIG_SETMASK, &sigmask, nullptr)); | | 126 | + const int err = pthread_create(&thread, &attr, StartIoThreadMain, nullptr); | 130 | 127 | CHECK_EQ(0, pthread_attr_destroy(&attr)); | 131 | 128 | if (err != 0) { | | 129 | + // Restore original mask | | 130 | + CHECK_EQ(0, pthread_sigmask(SIG_SETMASK, &sigmask, nullptr)); | 132 | 131 | fprintf(stderr, "node[%u]: pthread_create: %s\n", | 133 | 132 | uv_os_getpid(), strerror(err)); | 134 | 133 | fflush(stderr); | @@ -137,6 +136,8 @@ static int StartDebugSignalHandler() { | 137 | 136 | return -err; | 138 | 137 | } | 139 | 138 | RegisterSignalHandler(SIGUSR1, StartIoThreadWakeup); | | 139 | + // Restore original mask | | 140 | + CHECK_EQ(0, pthread_sigmask(SIG_SETMASK, &sigmask, nullptr)); | 140 | 141 | // Unblock SIGUSR1. A pending SIGUSR1 signal will now be delivered. | 141 | 142 | sigemptyset(&sigmask); | 142 | 143 | sigaddset(&sigmask, SIGUSR1); | |
Collapse file Copy file name to clipboardExpand all lines: src/node_watchdog.cc +4-1Lines changed: 4 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -308,7 +308,10 @@ int SigintWatchdogHelper::Start() { | 308 | 308 | CHECK_EQ(0, pthread_sigmask(SIG_SETMASK, &sigmask, &savemask)); | 309 | 309 | sigmask = savemask; | 310 | 310 | int ret = pthread_create(&thread_, nullptr, RunSigintWatchdog, nullptr); | 311 | | - CHECK_EQ(0, pthread_sigmask(SIG_SETMASK, &sigmask, nullptr)); | | 311 | + | | 312 | + auto cleanup = OnScopeLeave( | | 313 | + [&]() { CHECK_EQ(0, pthread_sigmask(SIG_SETMASK, &sigmask, nullptr)); }); | | 314 | + | 312 | 315 | if (ret != 0) { | 313 | 316 | return ret; | 314 | 317 | } | |
|