summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLucio Andrés Illanes Albornoz <lucio@lucioillanes.de>2020-02-29 13:17:19 +0000
committerLucio Andrés Illanes Albornoz <lucio@lucioillanes.de>2020-02-29 13:17:19 +0000
commitfa4a80dd5993cc64a72c92a450b3a25e3949eb4f (patch)
treece7031517179866c8448a0d24a7e5822e6c5a470
parent339f40adfad8f4577d9fca6b0f02788af7ee87f0 (diff)
downloadmidipix_build-fa4a80dd5993cc64a72c92a450b3a25e3949eb4f.tar.bz2
midipix_build-fa4a80dd5993cc64a72c92a450b3a25e3949eb4f.tar.xz
build.sh:buildp_ast(): correctly call rtl_kill_tree().
subr/rtl_complex.subr:rtl_kill_tree(): iteratively & recursively kill tree of processes excluding ${$}.
-rwxr-xr-xbuild.sh8
-rw-r--r--subr/rtl_complex.subr16
2 files changed, 14 insertions, 10 deletions
diff --git a/build.sh b/build.sh
index c6499304..16087116 100755
--- a/build.sh
+++ b/build.sh
@@ -3,16 +3,16 @@
#
buildp_ast() {
- local _param="${1}" _pids_killed="";
+ local _param="${1}" RTL_KILL_TREE_PIDS="";
if [ "${_param}" = "abort" ]; then
rtl_log_msg failexit "Build aborted.";
fi;
if [ -n "${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME}" ]; then
rtl_fileop rm "${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME}";
fi;
- if rtl_kill_tree "${$}"\
- && [ -n "${_pids_killed}" ]; then
- rtl_log_msg vnfo "Killed PIDs ${_pids_killed}";
+ if rtl_kill_tree "${$}" "TERM"\
+ && [ -n "${RTL_KILL_TREE_PIDS}" ]; then
+ rtl_log_msg vnfo "Killed PIDs ${RTL_KILL_TREE_PIDS}";
fi;
};
diff --git a/subr/rtl_complex.subr b/subr/rtl_complex.subr
index 6d9750dc..8370a4cf 100644
--- a/subr/rtl_complex.subr
+++ b/subr/rtl_complex.subr
@@ -75,13 +75,17 @@ rtl_head() {
};
rtl_kill_tree() {
- local _pid="${1}" _signal="TERM" _pid_child="" _pid_top="";
- for _pid_top in $(pgrep -P "${_pid}"); do
- for _pid_child in $(pgrep -P "${_pid_top}" 2>/dev/null); do
- _pids_killed="${_pids_killed:+${_pids_killed} }${_pid_child}"; kill "-${_signal}" "${_pid_child}" 2>/dev/null;
+ local _pid="${1}" _signal="${2:-TERM}" _pid_child="" _pids="";
+ if _pids="$(pgrep -P "${_pid}")"\
+ && [ -n "${_pids}" ]; then
+ for _pid_child in ${_pids}; do
+ rtl_kill_tree "${_pid_child}" "${_signal}";
done;
- _pids_killed="${_pids_killed:+${_pids_killed} }${_pid_top}"; kill "-${_signal}" "${_pid_top}" 2>/dev/null;
- done;
+ fi;
+ if [ "${_pid:-0}" -ne "${$}" ]\
+ && kill "-${_signal}" "${_pid}" 2>/dev/null; then
+ RTL_KILL_TREE_PIDS="$(rtl_lconcat "${RTL_KILL_TREE_PIDS}" "${_pid}")";
+ fi;
};
rtl_run_cmd_unsplit() {