Skip to content

Commit

Permalink
build: don't squash signal handlers with --shared
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Stewart X Addison committed Jan 16, 2017
1 parent e407478 commit 4709683
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2192,7 +2192,7 @@ static void WaitForInspectorDisconnect(Environment* env) {
if (env->inspector_agent()->IsConnected()) {
// Restore signal dispositions, the app is done and is no longer
// capable of handling signals.
#ifdef __POSIX__
#if defined(__POSIX__) && !defined(NODE_SHARED_MODE)
struct sigaction act;
memset(&act, 0, sizeof(act));
for (unsigned nr = 1; nr < kMaxSignal; nr += 1) {
Expand Down Expand Up @@ -4093,6 +4093,7 @@ inline void PlatformInit() {

CHECK_EQ(err, 0);

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

RegisterSignalHandler(SIGINT, SignalExit, true);
RegisterSignalHandler(SIGTERM, SignalExit, true);
Expand Down

0 comments on commit 4709683

Please sign in to comment.