Skip to content

Commit b7c5295

Browse files
Stewart X AddisonMylesBorins
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 ccb6045 commit b7c5295

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
@@ -2248,7 +2248,7 @@ static void WaitForInspectorDisconnect(Environment* env) {
22482248
if (env->inspector_agent()->IsConnected()) {
22492249
// Restore signal dispositions, the app is done and is no longer
22502250
// capable of handling signals.
2251-
#ifdef __POSIX__
2251+
#if defined(__POSIX__) && !defined(NODE_SHARED_MODE)
22522252
struct sigaction act;
22532253
memset(&act, 0, sizeof(act));
22542254
for (unsigned nr = 1; nr < kMaxSignal; nr += 1) {
@@ -4254,6 +4254,7 @@ inline void PlatformInit() {
42544254

42554255
CHECK_EQ(err, 0);
42564256

4257+
#ifndef NODE_SHARED_MODE
42574258
// Restore signal dispositions, the parent process may have changed them.
42584259
struct sigaction act;
42594260
memset(&act, 0, sizeof(act));
@@ -4267,6 +4268,7 @@ inline void PlatformInit() {
42674268
act.sa_handler = (nr == SIGPIPE) ? SIG_IGN : SIG_DFL;
42684269
CHECK_EQ(0, sigaction(nr, &act, nullptr));
42694270
}
4271+
#endif // !NODE_SHARED_MODE
42704272

42714273
RegisterSignalHandler(SIGINT, SignalExit, true);
42724274
RegisterSignalHandler(SIGTERM, SignalExit, true);

0 commit comments

Comments
 (0)