Skip to content

Commit

Permalink
hot-restarter.py: revert SIGCHLD handler to force kill instead of term (
Browse files Browse the repository at this point in the history
envoyproxy#2640)

PR: envoyproxy#2596 changed the behavior of the SIGTERM and SIGCHLD handlers to
attempt to allow child processes to exit gracefully before force killing
them. This PR reverts the behavior of the SIGCHLD handler back to force
killing children if a child exits uncleanly. This should allow the
supervisor of the python process (e.g. runit) to restart envoy with a
shorter delay (whereas an attempt at graceful TERM might delay up to
TERM_WAIT_SECONDS).

Note: If the child process of hot-restarter.py is a container framework
(e.g. runc), the force kill might result in container state being
leaked. This should hopefully be a rare occurrence.

Signed-off-by: Michael Puncel <[email protected]>
  • Loading branch information
mpuncel authored and htuch committed Feb 22, 2018
1 parent e88442b commit ade5deb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions restarter/hot-restarter.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,12 @@ def sigchld_handler(signum, frame):
kill_all_and_exit = True

if kill_all_and_exit:
print "Due to abnormal exit, terminating all child processes and exiting"
term_all_children()
print "Due to abnormal exit, force killing all child processes and exiting"

# First uninstall the SIGCHLD handler so that we don't get called again.
signal.signal(signal.SIGCHLD, signal.SIG_DFL)

force_kill_all_children()

# Our last child died, so we have no purpose. Exit.
if not pid_list:
Expand Down

0 comments on commit ade5deb

Please sign in to comment.