diff --git a/scripts/node.sh b/scripts/node.sh index 6239e8fe7..41bec7f39 100755 --- a/scripts/node.sh +++ b/scripts/node.sh @@ -237,6 +237,29 @@ kill_child() { kill "${pid}" } +# Kill nodes that are direct child of this script (pid $$), +# i.e. run directly from main loop. +kill_node() { + local pids pid delay + + msg "finding node processes that are our children" + pids=$( + ps axcwwo "pid=,ppid=,command=" | + awk -v me=$$ '$2 == me && $3 == "harmony" { print $1; }' + ) + msg "found node processes: ${pids:-""}" + for pid in ${pids} + do + delay=0 + while kill_child ${pid} + do + sleep ${delay} + delay=1 + done + msg "pid ${pid} no longer running" + done +} + { # TODO ek – implement me } &