Skip to content

Commit e7f72a4

Browse files
Stewart X Addisonitaloacasas
Stewart X Addison
authored andcommitted
build: don't squash signal handlers with --shared
An application using node built as a shared library may legitimately implement its own signal handling routines. Current behaviour is to squash all signal handlers on node startup. This change will stop that behaviour when node is built as a shared library. PR-URL: nodejs#10539 Fixes: nodejs#10520 Refs: nodejs#615 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
1 parent 4ee840b commit e7f72a4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/node.cc

+3-1
Original file line numberDiff line numberDiff line change
@@ -2187,7 +2187,7 @@ static void WaitForInspectorDisconnect(Environment* env) {
21872187
if (env->inspector_agent()->IsConnected()) {
21882188
// Restore signal dispositions, the app is done and is no longer
21892189
// capable of handling signals.
2190-
#ifdef __POSIX__
2190+
#if defined(__POSIX__) && !defined(NODE_SHARED_MODE)
21912191
struct sigaction act;
21922192
memset(&act, 0, sizeof(act));
21932193
for (unsigned nr = 1; nr < kMaxSignal; nr += 1) {
@@ -4069,6 +4069,7 @@ inline void PlatformInit() {
40694069

40704070
CHECK_EQ(err, 0);
40714071

4072+
#ifndef NODE_SHARED_MODE
40724073
// Restore signal dispositions, the parent process may have changed them.
40734074
struct sigaction act;
40744075
memset(&act, 0, sizeof(act));
@@ -4082,6 +4083,7 @@ inline void PlatformInit() {
40824083
act.sa_handler = (nr == SIGPIPE) ? SIG_IGN : SIG_DFL;
40834084
CHECK_EQ(0, sigaction(nr, &act, nullptr));
40844085
}
4086+
#endif // !NODE_SHARED_MODE
40854087

40864088
RegisterSignalHandler(SIGINT, SignalExit, true);
40874089
RegisterSignalHandler(SIGTERM, SignalExit, true);

0 commit comments

Comments
 (0)