Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quit child processes when supervisor crashes (Linux only) #199

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions supervisor/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from supervisor import events

from supervisor.datatypes import RestartUnconditionally
from supervisor.datatypes import signal_number

from supervisor.socket_manager import SocketManager

Expand Down Expand Up @@ -284,6 +285,19 @@ def _spawn_as_child(self, filename, argv):
# Presumably it also prevents HUP, etc received by
# supervisord from being sent to children.
options.setpgrp()

# Send this process a kill signal if supervisor crashes.
# Uses system call prctl(PR_SET_PDEATHSIG, <signal>).
# This will only work on Linux.
try:
import ctypes
import ctypes.util
libc = ctypes.cdll.LoadLibrary(ctypes.util.find_library('c'))
libc.prctl(1, signal.SIGKILL)
except Exception, e:
options.logger.debug("Could not set parent death signal. "
"This is expected if not running on Linux.")

self._prepare_child_fds()
# sending to fd 2 will put this output in the stderr log
msg = self.set_uid()
Expand Down