FW: Zabit i podprocesy

Peter Ronai linux na my-scotland.sk
Úterý Leden 28 17:09:57 CET 2003


dopredu soraz za OT lebo som nejak som nezachytil celu debatu ale pokial
ide len o postupne killnutie potomkov od konca tak pokial nie je nic
lepsie naporudzi da sa to takto neohrabane ;)

declare -a a
declare -i count=0
a[0]=$1
children ()
{
   ps -efH | awk -F" " '{print $2" "$3}' | grep -v PID | grep -vE '\
[01]$' | while read pid ppid; do
        for ar in `seq 0 $count`; do
           if [ "$ppid" != 0 ] && [ "$[a[$ar]]" == "$ppid" ]; then
                count=count+1
                a[$count]=$pid
                echo ${a[$count]}
           fi
        done
   done
}
for pid2kill in `children $1 | sort -nr`; do
        kill $pid2kill
done
kill a[0]=$1


________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information on a proactive anti-virus service working
around the clock, around the globe, visit http://www.messagelabs.com
________________________________________________________________________


Další informace o konferenci Linux