Skip to content

Commit

Permalink
src: add missing sigemptyset() to init sigset_t
Browse files Browse the repository at this point in the history
  • Loading branch information
mcpiroman authored and aduh95 committed Feb 11, 2022
1 parent 0185464 commit 5c29eda
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ struct V8Platform v8_platform;
} // namespace per_process

#ifdef __POSIX__

void SignalExit(int signo, siginfo_t* info, void* ucontext) {
ResetStdio();
raise(signo);
Expand Down Expand Up @@ -548,6 +549,7 @@ void TrapWebAssemblyOrContinue(int signo, siginfo_t* info, void* ucontext) {
struct sigaction sa;
memset(&sa, 0, sizeof(sa));
sa.sa_handler = SIG_DFL;
sigemptyset(&sa.sa_mask);
CHECK_EQ(sigaction(signo, &sa, nullptr), 0);

ResetStdio();
Expand All @@ -574,8 +576,8 @@ void RegisterSignalHandler(int signal,
struct sigaction sa;
memset(&sa, 0, sizeof(sa));
sa.sa_sigaction = handler;
sa.sa_flags = reset_handler ? SA_RESETHAND : 0;
sigfillset(&sa.sa_mask);
sa.sa_flags = reset_handler ? SA_RESETHAND : 0;
CHECK_EQ(sigaction(signal, &sa, nullptr), 0);
}
#endif // __POSIX__
Expand Down Expand Up @@ -623,6 +625,7 @@ inline void PlatformInit() {
// Restore signal dispositions, the parent process may have changed them.
struct sigaction act;
memset(&act, 0, sizeof(act));
sigemptyset(&act.sa_mask);

// The hard-coded upper limit is because NSIG is not very reliable; on Linux,
// it evaluates to 32, 34 or 64, depending on whether RT signals are enabled.
Expand Down Expand Up @@ -675,6 +678,7 @@ inline void PlatformInit() {
struct sigaction sa;
memset(&sa, 0, sizeof(sa));
sa.sa_sigaction = TrapWebAssemblyOrContinue;
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_SIGINFO;
CHECK_EQ(sigaction(SIGSEGV, &sa, nullptr), 0);
}
Expand Down
1 change: 1 addition & 0 deletions src/node_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ int main(int argc, char* argv[]) {
struct sigaction act;
memset(&act, 0, sizeof(act));
act.sa_handler = SIG_IGN;
sigemptyset(&act.sa_mask);
sigaction(SIGPIPE, &act, nullptr);
}
#endif
Expand Down

0 comments on commit 5c29eda

Please sign in to comment.