Skip to content

Commit

Permalink
arbiter: Reinstall SIGCHLD as required by some UNIXes
Browse files Browse the repository at this point in the history
According to the python signal documentation[1], SIGCHLD is handled
differently from other signals. Specifically, if the underlying
implementation resets the SIGCHLD signal handler, then python won't
reinstall it (as it does for other signals).

This behavior doesn't seem to exist for neither Linux nor Mac, but
perhaps one could argue that it's good practise anyway.

[1] https://docs.python.org/3/library/signal.html
  • Loading branch information
sylt committed Feb 3, 2024
1 parent 670a831 commit a0633e8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions gunicorn/arbiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ def signal(self, sig, frame):
""" Note: Signal context! No logging or memory allocations allowed. """
self.write_message_to_pipe(sig)

# Some UNIXes require SIGCHLD to be reinstalled, see python signal docs
if sig == signal.SIGCHLD:
signal.signal(sig, self.signal)

def run(self):
"Main master loop."
self.start()
Expand Down

0 comments on commit a0633e8

Please sign in to comment.