
On Fri, Jun 28, 2013 at 12:59:50PM +1000, Chris Samuel wrote:
Actually thanks to Craig no recursion is necessary, I had to modify my version as Craigs seemed to have issues with processes that were numbers, but what I ended up with was:
pstree -l -A -p $(pidof pbs_mom) | sed -e 's/(/\n/g' | sed -e 's/).*//' | egrep '^[1-9]+' | fgrep -v $(pidof pbs_mom)
So that will find you all the children (processes and threads) of pbs_mom excluding pbs_mom itself.
this may be good enough for many cases, but it'll be wrong in the case of processes that are rapidly forking. I'm not sure what your exact use case is, but in general cgroups are the best way to keep track of processes. once the moment-in-time info is snapshotted for userspace (eg. pstree) to use it's already out of date, wheras things like cgroup freeze/thaw and kills are definitive if used properly. ie. no rogue processes are possible. cheers, robin