diff options
author | Fedor Indutny <fedor@indutny.com> | 2015-03-19 22:03:34 -0700 |
---|---|---|
committer | Julien Gilli <julien.gilli@joyent.com> | 2015-03-27 18:03:55 -0700 |
commit | 61fe1fe21ba281b05b90a632e2dad29eefb14a0a (patch) | |
tree | b81afd58a00267df8899af7b006d0430ffe539af /src/node.cc | |
parent | d6484f3f7b1b90987065736fcc7d52e005293b53 (diff) | |
download | node-new-61fe1fe21ba281b05b90a632e2dad29eefb14a0a.tar.gz |
src: backport fix for SIGINT crash on FreeBSD
This is a backport of b64983d77cc3ed2e4b585f3bfc8ed23802389a52.
Original commit message:
src: reset signal handler to SIG_DFL on FreeBSD
FreeBSD has a nasty bug with SA_RESETHAND reseting the SA_SIGINFO,
that is in turn set for a libthr wrapper. This leads to a crash.
Work around the issue by manually setting SIG_DFL in the signal
handler.
Fix: https://github.com/joyent/node/issues/9326
PR-URL: https://github.com/iojs/io.js/pull/1218
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Fixes #9326.
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
PR-URL: https://github.com/joyent/node/pull/14184
Diffstat (limited to 'src/node.cc')
-rw-r--r-- | src/node.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/node.cc b/src/node.cc index c8dfe04121..f0590d5a72 100644 --- a/src/node.cc +++ b/src/node.cc @@ -2785,6 +2785,13 @@ static void AtExit() { static void SignalExit(int signo) { uv_tty_reset_mode(); +#ifdef __FreeBSD__ + // FreeBSD has a nasty bug, see RegisterSignalHandler for details + struct sigaction sa; + memset(&sa, 0, sizeof(sa)); + sa.sa_handler = SIG_DFL; + CHECK_EQ(sigaction(signo, &sa, nullptr), 0); +#endif raise(signo); } @@ -3163,7 +3170,12 @@ static void RegisterSignalHandler(int signal, struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_handler = handler; +#ifndef __FreeBSD__ + // FreeBSD has a nasty bug with SA_RESETHAND reseting the SA_SIGINFO, that is + // in turn set for a libthr wrapper. This leads to a crash. + // Work around the issue by manually setting SIG_DFL in the signal handler sa.sa_flags = reset_handler ? SA_RESETHAND : 0; +#endif sigfillset(&sa.sa_mask); CHECK_EQ(sigaction(signal, &sa, NULL), 0); } |