Skip to content

Commit 0f0f3d3

Browse files
Stewart X Addisongibfahn
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: #10539 Fixes: #10520 Refs: #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 e050c34 commit 0f0f3d3

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
@@ -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) {
@@ -4099,6 +4099,7 @@ inline void PlatformInit() {
40994099

41004100
CHECK_EQ(err, 0);
41014101

4102+
#ifndef NODE_SHARED_MODE
41024103
// Restore signal dispositions, the parent process may have changed them.
41034104
struct sigaction act;
41044105
memset(&act, 0, sizeof(act));
@@ -4112,6 +4113,7 @@ inline void PlatformInit() {
41124113
act.sa_handler = (nr == SIGPIPE) ? SIG_IGN : SIG_DFL;
41134114
CHECK_EQ(0, sigaction(nr, &act, nullptr));
41144115
}
4116+
#endif // !NODE_SHARED_MODE
41154117

41164118
RegisterSignalHandler(SIGINT, SignalExit, true);
41174119
RegisterSignalHandler(SIGTERM, SignalExit, true);

0 commit comments

Comments
 (0)