Mercurial > hg > aboriginal
diff sources/functions.sh @ 778:e373d2b6d0b8
Add killtree and make stuff use it. Update smoketest-all.sh to use doforklog, allowing FORK=1 to run stuff in parallel.
author | Rob Landley <rob@landley.net> |
---|---|
date | Fri, 03 Jul 2009 05:29:11 -0500 |
parents | 879353d1cfba |
children | db06a8c1bfed |
line wrap: on
line diff
--- a/sources/functions.sh Thu Jul 02 16:23:39 2009 -0500 +++ b/sources/functions.sh Fri Jul 03 05:29:11 2009 -0500 @@ -563,9 +563,29 @@ if [ ! -z "$FORK" ] then - $* 2>&1 | tee "$LOG" | grep '^===' & + $* 2>&1 | eval "tee \"$LOG\" $QUIET" & else - $* 2>&1 | tee "$LOG" + $* 2>&1 | eval "tee \"$LOG\" $QUIET" fi } +# Kill a process and all its decendants + +function killtree() +{ + local KIDS="" + + while [ $# -ne 0 ] + do + KIDS="$KIDS $(pgrep -P$1)" + shift + done + + KIDS="$(echo -n $KIDS)" + if [ ! -z "$KIDS" ] + then + # Depth first kill avoids reparent_to_init hiding stuff. + killtree $KIDS + kill $KIDS 2>/dev/null + fi +}