Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 517a93d

Browse files
committedAug 6, 2020
src: set SA_SIGINFO flag when using sa_sigaction
For `sigaction()` the `SA_SIGINFO` flag should be set when setting the handler via the `sa_sigaction` member of the `sigaction` struct.
1 parent 22cbbcf commit 517a93d

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed
 

‎src/node.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ void RegisterSignalHandler(int signal,
543543
struct sigaction sa;
544544
memset(&sa, 0, sizeof(sa));
545545
sa.sa_sigaction = handler;
546-
sa.sa_flags = reset_handler ? SA_RESETHAND : 0;
546+
sa.sa_flags = reset_handler ? SA_RESETHAND | SA_SIGINFO : SA_SIGINFO;
547547
sigfillset(&sa.sa_mask);
548548
CHECK_EQ(sigaction(signal, &sa, nullptr), 0);
549549
}
@@ -638,6 +638,7 @@ inline void PlatformInit() {
638638
struct sigaction sa;
639639
memset(&sa, 0, sizeof(sa));
640640
sa.sa_sigaction = TrapWebAssemblyOrContinue;
641+
sa.sa_flags = SA_SIGINFO;
641642
CHECK_EQ(sigaction(SIGSEGV, &sa, nullptr), 0);
642643
}
643644
V8::EnableWebAssemblyTrapHandler(false);

‎test/addons/register-signal-handler/binding.cc

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ using v8::Value;
1313
void Handler(int signo, siginfo_t* siginfo, void* ucontext) {
1414
char signo_char = signo;
1515
int written;
16+
assert(signo == siginfo->si_signo);
1617
do {
1718
written = write(1, &signo_char, 1); // write() is signal-safe.
1819
} while (written == -1 && errno == EINTR);

0 commit comments

Comments
 (0)
Please sign in to comment.