From ade5deb8d0070325acbd5714b14cca73ca50a7b9 Mon Sep 17 00:00:00 2001 From: Michael Puncel Date: Wed, 21 Feb 2018 23:07:55 -0500 Subject: [PATCH] hot-restarter.py: revert SIGCHLD handler to force kill instead of term (#2640) PR: #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 --- restarter/hot-restarter.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/restarter/hot-restarter.py b/restarter/hot-restarter.py index f2f218909b2d..56af6cb9a407 100644 --- a/restarter/hot-restarter.py +++ b/restarter/hot-restarter.py @@ -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: