From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id CD4101396D1 for ; Fri, 15 Sep 2017 18:31:45 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id E58D61FC05F; Fri, 15 Sep 2017 18:31:44 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id B0ABA1FC05F for ; Fri, 15 Sep 2017 18:31:44 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 840DD33BEA7 for ; Fri, 15 Sep 2017 18:31:43 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id ECD958F73 for ; Fri, 15 Sep 2017 18:31:41 +0000 (UTC) From: "William Hubbs" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "William Hubbs" Message-ID: <1505423840.6a5ca2ab368d0a85f51bb559672dba2e3ffcc6be.williamh@OpenRC> Subject: [gentoo-commits] proj/openrc:master commit in: sh/, etc/ X-VCS-Repository: proj/openrc X-VCS-Files: etc/rc.conf sh/rc-cgroup.sh.in X-VCS-Directories: etc/ sh/ X-VCS-Committer: williamh X-VCS-Committer-Name: William Hubbs X-VCS-Revision: 6a5ca2ab368d0a85f51bb559672dba2e3ffcc6be X-VCS-Branch: master Date: Fri, 15 Sep 2017 18:31:41 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 17b11520-a69f-4f06-afdb-197a58ad54df X-Archives-Hash: e810a8564cc754c59b63125a23f94da6 commit: 6a5ca2ab368d0a85f51bb559672dba2e3ffcc6be Author: William Hubbs gmail com> AuthorDate: Thu Sep 14 16:40:26 2017 +0000 Commit: William Hubbs gentoo org> CommitDate: Thu Sep 14 21:17:20 2017 +0000 URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=6a5ca2ab make the procedure for killing child processes of services configurable etc/rc.conf | 29 ++++++++++++++++++++++++++--- sh/rc-cgroup.sh.in | 13 ++++++++----- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/etc/rc.conf b/etc/rc.conf index d9ad911d..b7296d35 100644 --- a/etc/rc.conf +++ b/etc/rc.conf @@ -277,10 +277,33 @@ rc_tty_number=12 # Set this to YES if you want all of the processes in a service's cgroup # killed when the service is stopped or restarted. -# This should not be set globally because it kills all of the service's -# child processes, and most of the time this is undesirable. Please set -# it in /etc/conf.d/. +# Be aware that setting this to yes means all of a service's +# child processes will be killed. Keep this in mind if you set this to +# yes here instead of for the individual services in +# /etc/conf.d/. # To perform this cleanup manually for a stopped service, you can # execute cgroup_cleanup with /etc/init.d/ cgroup_cleanup or # rc-service cgroup_cleanup. +# The process followed in this cleanup is the following: +# 1. send stopsig (sigterm if it isn't set) to all processes left in the +# cgroup immediately followed by sigcont. +# 2. Send sighup to all processes in the cgroup if rc_send_sighup is +# yes. +# 3. delay for rc_timeout_stopsec seconds. +# 4. send sigkill to all processes in the cgroup unless disabled by +# setting rc_send_sigkill to no. # rc_cgroup_cleanup="NO" + +# If this is yes, we will send sighup to the processes in the cgroup +# immediately after stopsig and sigcont. +#rc_send_sighup="NO" + +# This is the amount of time in seconds that we delay after sending sigcont +# and optionally sighup, before we optionally send sigkill to all +# processes in the # cgroup. +# The default is 90 seconds. +#rc_timeout_stopsec="90" + +# If this is set to no, we do not send sigkill to all processes in the +# cgroup. +#rc_send_sigkill="YES" diff --git a/sh/rc-cgroup.sh.in b/sh/rc-cgroup.sh.in index 47a007b6..4b713594 100644 --- a/sh/rc-cgroup.sh.in +++ b/sh/rc-cgroup.sh.in @@ -204,10 +204,13 @@ cgroup_cleanup() local pids pids="$(cgroup_get_pids)" if [ -n "${pids}" ]; then - kill -s TERM "${pids}" - sleep 1 - pids="$(cgroup_get_pids)" - [ -n "${pids}" ] && - kill -s KILL "${pids}" + kill -s "${stopsig:-SIGTERM}" ${pids} 2> /dev/null + kill -s SIGCONT ${pids} 2> /dev/null + yesno "${rc_send_sighup:-no}" && + kill -s SIGHUP ${pids} 2> /dev/null + sleep "${rc_timeout_stopsec:-90}" + yesno "${rc_send_sigkill:-yes}" && + kill -s SIGKILL ${pids} 2> /dev/null fi + eend 0 }