> Shouldn't you be using %r to get pgid? ps -eo user,pid,pgid does what
> I'd expect it to.
Yup. That woulda done it. But how did you find that? In my man page, %r
is "resident set size" which seems to be wrong...
Oh well. Either way, I already wrote the python script to identify all the
descendents of a given pid. If anyone cares, here it is:
#!/usr/bin/python
import re,commands,sys
processlist=[]
def searchforchildrenof(pid):
searchfor(pid)
print ""
def searchfor(pid):
sys.stdout.write(pid+" ")
for process in processlist:
if ( process[1] == pid ):
searchfor(process[0])
def main():
if len(sys.argv) != 2:
print "Displays a list of all the child PIDs that came from a specified
PID"
print "Usage: "+sys.argv[0]+" pid"
sys.exit(0)
oneOrMoreSpaces = re.compile(' +')
justOneSpace = ' '
# The "ps" command will give output like this:
# PID PPID
# 1 0
# 2 1
# ...
# So when we do the split(), we get the following:
# ['PID', 'PPID', '1', '0', '2', '1', ... ]
# So when we parse this, we casually ignore [0] and [1]
data = commands.getoutput('ps -e -o "%p%P"').split()
for i in range(2,len(data),2):
# data[i] is the PID, and data[i+1] is the PPID
processlist.append( [data[i],data[i+1]] )
searchforchildrenof(sys.argv[1])
if __name__ == "__main__" :
main()
_______________________________________________
Tech mailing list
[email protected]
http://lopsa.org/cgi-bin/mailman/listinfo/tech
This list provided by the League of Professional System Administrators
http://lopsa.org/