Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 24dabf8

Browse filesBrowse files
dvyukovdanielleadams
authored andcommitted
src: don't reset embeder signal handlers
The only bad handler value we can inhert from before exec is SIG_IGN (any actual function pointer is reset to SIG_DFL during exec). If that's the case, we want to reset it back to SIG_DFL. However, it's also possible that an embeder (or an LD_PRELOAD-ed library) has set up own signal handler for own purposes (e.g. profiling). If that's the case, keep it intact. Fix #47013 PR-URL: #47188 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent c7dc6e3 commit 24dabf8
Copy full SHA for 24dabf8

File tree

Expand file treeCollapse file tree

1 file changed

+11
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-0
lines changed
Open diff view settings
Collapse file

‎src/node.cc‎

Copy file name to clipboardExpand all lines: src/node.cc
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,17 @@ void ResetSignalHandlers() {
458458
if (nr == SIGKILL || nr == SIGSTOP)
459459
continue;
460460
act.sa_handler = (nr == SIGPIPE || nr == SIGXFSZ) ? SIG_IGN : SIG_DFL;
461+
if (act.sa_handler == SIG_DFL) {
462+
// The only bad handler value we can inhert from before exec is SIG_IGN
463+
// (any actual function pointer is reset to SIG_DFL during exec).
464+
// If that's the case, we want to reset it back to SIG_DFL.
465+
// However, it's also possible that an embeder (or an LD_PRELOAD-ed
466+
// library) has set up own signal handler for own purposes
467+
// (e.g. profiling). If that's the case, we want to keep it intact.
468+
struct sigaction old;
469+
CHECK_EQ(0, sigaction(nr, nullptr, &old));
470+
if ((old.sa_flags & SA_SIGINFO) || old.sa_handler != SIG_IGN) continue;
471+
}
461472
CHECK_EQ(0, sigaction(nr, &act, nullptr));
462473
}
463474
#endif // __POSIX__

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.