Skip to content

Commit 4709683

Browse files
author
Stewart X Addison
committed
build: don't squash signal handlers with --shared
Fixes: #10520 Ref: dd47a8c 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.
1 parent e407478 commit 4709683

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/node.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2192,7 +2192,7 @@ static void WaitForInspectorDisconnect(Environment* env) {
21922192
if (env->inspector_agent()->IsConnected()) {
21932193
// Restore signal dispositions, the app is done and is no longer
21942194
// capable of handling signals.
2195-
#ifdef __POSIX__
2195+
#if defined(__POSIX__) && !defined(NODE_SHARED_MODE)
21962196
struct sigaction act;
21972197
memset(&act, 0, sizeof(act));
21982198
for (unsigned nr = 1; nr < kMaxSignal; nr += 1) {
@@ -4093,6 +4093,7 @@ inline void PlatformInit() {
40934093

40944094
CHECK_EQ(err, 0);
40954095

4096+
#ifndef NODE_SHARED_MODE
40964097
// Restore signal dispositions, the parent process may have changed them.
40974098
struct sigaction act;
40984099
memset(&act, 0, sizeof(act));
@@ -4106,6 +4107,7 @@ inline void PlatformInit() {
41064107
act.sa_handler = (nr == SIGPIPE) ? SIG_IGN : SIG_DFL;
41074108
CHECK_EQ(0, sigaction(nr, &act, nullptr));
41084109
}
4110+
#endif // !NODE_SHARED_MODE
41094111

41104112
RegisterSignalHandler(SIGINT, SignalExit, true);
41114113
RegisterSignalHandler(SIGTERM, SignalExit, true);

0 commit comments

Comments
 (0)