Codebase list openrc / 6a5ca2a
make the procedure for killing child processes of services configurable William Hubbs 6 years ago
2 changed file(s) with 36 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
276276
277277 # Set this to YES if you want all of the processes in a service's cgroup
278278 # killed when the service is stopped or restarted.
279 # This should not be set globally because it kills all of the service's
280 # child processes, and most of the time this is undesirable. Please set
281 # it in /etc/conf.d/<service>.
279 # Be aware that setting this to yes means all of a service's
280 # child processes will be killed. Keep this in mind if you set this to
281 # yes here instead of for the individual services in
282 # /etc/conf.d/<service>.
282283 # To perform this cleanup manually for a stopped service, you can
283284 # execute cgroup_cleanup with /etc/init.d/<service> cgroup_cleanup or
284285 # rc-service <service> cgroup_cleanup.
286 # The process followed in this cleanup is the following:
287 # 1. send stopsig (sigterm if it isn't set) to all processes left in the
288 # cgroup immediately followed by sigcont.
289 # 2. Send sighup to all processes in the cgroup if rc_send_sighup is
290 # yes.
291 # 3. delay for rc_timeout_stopsec seconds.
292 # 4. send sigkill to all processes in the cgroup unless disabled by
293 # setting rc_send_sigkill to no.
285294 # rc_cgroup_cleanup="NO"
295
296 # If this is yes, we will send sighup to the processes in the cgroup
297 # immediately after stopsig and sigcont.
298 #rc_send_sighup="NO"
299
300 # This is the amount of time in seconds that we delay after sending sigcont
301 # and optionally sighup, before we optionally send sigkill to all
302 # processes in the # cgroup.
303 # The default is 90 seconds.
304 #rc_timeout_stopsec="90"
305
306 # If this is set to no, we do not send sigkill to all processes in the
307 # cgroup.
308 #rc_send_sigkill="YES"
203203 local pids
204204 pids="$(cgroup_get_pids)"
205205 if [ -n "${pids}" ]; then
206 kill -s TERM "${pids}"
207 sleep 1
208 pids="$(cgroup_get_pids)"
209 [ -n "${pids}" ] &&
210 kill -s KILL "${pids}"
211 fi
212 }
206 kill -s "${stopsig:-SIGTERM}" ${pids} 2> /dev/null
207 kill -s SIGCONT ${pids} 2> /dev/null
208 yesno "${rc_send_sighup:-no}" &&
209 kill -s SIGHUP ${pids} 2> /dev/null
210 sleep "${rc_timeout_stopsec:-90}"
211 yesno "${rc_send_sigkill:-yes}" &&
212 kill -s SIGKILL ${pids} 2> /dev/null
213 fi
214 eend 0
215 }