From 579af5d6786f62008807a473749600e88cea21fc Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Thu, 23 Jan 2014 11:32:22 -0600 Subject: [PATCH] Kill process groups in screen_stop() Previously only the top child process was killed, killing the process group also takes all of the child processes with it. Closes-bug: 1271889 Change-Id: If1864cc4f1944f417ea3473d81d8b6e8e40030c2 --- functions | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/functions b/functions index 92b61ed974..13d021e147 100644 --- a/functions +++ b/functions @@ -1150,6 +1150,9 @@ function screen_it { # Stop a service in screen +# If a PID is available use it, kill the whole process group via TERM +# If screen is being used kill the screen window; this will catch processes +# that did not leave a PID behind # screen_stop service function screen_stop() { SCREEN_NAME=${SCREEN_NAME:-stack} @@ -1159,7 +1162,7 @@ function screen_stop() { if is_service_enabled $1; then # Kill via pid if we have one available if [[ -r $SERVICE_DIR/$SCREEN_NAME/$1.pid ]]; then - pkill -TERM -P $(cat $SERVICE_DIR/$SCREEN_NAME/$1.pid) + pkill -TERM -P -$(cat $SERVICE_DIR/$SCREEN_NAME/$1.pid) rm $SERVICE_DIR/$SCREEN_NAME/$1.pid fi if [[ "$USE_SCREEN" = "True" ]]; then