Skip to content

Commit b9698f1

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 bfc48d7 commit b9698f1

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
@@ -2198,7 +2198,7 @@ static void WaitForInspectorDisconnect(Environment* env) {
21982198
if (env->inspector_agent()->IsConnected()) {
21992199
// Restore signal dispositions, the app is done and is no longer
22002200
// capable of handling signals.
2201-
#ifdef __POSIX__
2201+
#if defined(__POSIX__) && !defined(NODE_SHARED_MODE)
22022202
struct sigaction act;
22032203
memset(&act, 0, sizeof(act));
22042204
for (unsigned nr = 1; nr < kMaxSignal; nr += 1) {
@@ -4166,6 +4166,7 @@ inline void PlatformInit() {
41664166

41674167
CHECK_EQ(err, 0);
41684168

4169+
#ifndef NODE_SHARED_MODE
41694170
// Restore signal dispositions, the parent process may have changed them.
41704171
struct sigaction act;
41714172
memset(&act, 0, sizeof(act));
@@ -4179,6 +4180,7 @@ inline void PlatformInit() {
41794180
act.sa_handler = (nr == SIGPIPE) ? SIG_IGN : SIG_DFL;
41804181
CHECK_EQ(0, sigaction(nr, &act, nullptr));
41814182
}
4183+
#endif // !NODE_SHARED_MODE
41824184

41834185
RegisterSignalHandler(SIGINT, SignalExit, true);
41844186
RegisterSignalHandler(SIGTERM, SignalExit, true);

0 commit comments

Comments
 (0)