Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: don't reset embeder signal handlers #47188

Merged
merged 1 commit into from Mar 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/node.cc
Expand Up @@ -430,6 +430,17 @@ void ResetSignalHandlers() {
if (nr == SIGKILL || nr == SIGSTOP)
continue;
act.sa_handler = (nr == SIGPIPE || nr == SIGXFSZ) ? SIG_IGN : SIG_DFL;
if (act.sa_handler == SIG_DFL) {
// 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, we want to keep it intact.
struct sigaction old;
CHECK_EQ(0, sigaction(nr, nullptr, &old));
if ((old.sa_flags & SA_SIGINFO) || old.sa_handler != SIG_IGN) continue;
}
CHECK_EQ(0, sigaction(nr, &act, nullptr));
}
#endif // __POSIX__
Expand Down