Skip to content

Commit 3c0e5f0

Browse files
author
Stewart X Addison
committed
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 <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 868e5e6 commit 3c0e5f0

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

42264226
CHECK_EQ(err, 0);
42274227

4228+
#ifndef NODE_SHARED_MODE
42284229
// Restore signal dispositions, the parent process may have changed them.
42294230
struct sigaction act;
42304231
memset(&act, 0, sizeof(act));
@@ -4238,6 +4239,7 @@ inline void PlatformInit() {
42384239
act.sa_handler = (nr == SIGPIPE) ? SIG_IGN : SIG_DFL;
42394240
CHECK_EQ(0, sigaction(nr, &act, nullptr));
42404241
}
4242+
#endif // !NODE_SHARED_MODE
42414243

42424244
RegisterSignalHandler(SIGINT, SignalExit, true);
42434245
RegisterSignalHandler(SIGTERM, SignalExit, true);

0 commit comments

Comments
 (0)