I have a script that generates a bunch of background and child processes.
Code: Select all
# pstree -p 30130
script(30130)─┬─sit(30131)───{gmain}(30149)
├─script(30146)───yad(30150)
├─script(30164)───yad(30167)
└─sleep(30214)
Maybe the simplest is to start the script via terminal (rxvt -e script) and kill the terminal to exit. But what if I don't want a terminal hanging around?
After a lot of googling, I haven't found much else, since most suggestions, such as ps --ppid 30130 miss the background processes. This works, but it sure is awkward:
Code: Select all
# x=`pstree -p $$`
n=2 ; k="start" ; list="kill"
while [[ -n $k ]] ; do k=`echo $x | cut -d\( -f$n | cut -d\) -f1` ; list=$list" $k" ; let n++ ; done
$list
There must be a neater way to do this. Or at least a way to print out a list from pstree. I'll appreciate your information. Thanks