How to get all child processes id pid in c in linux

If I forkand the child process, and then execcreate more child processes (which themselves can create more processes), how can I get a list of pidall descendant processes from the first process?

Is there a better way, except for the loop /proc/and check PPid(parent process id) of each process?

+2
source share
2 answers

Iterating through / proc is the "standard" way to do this. The way psfriends ( pstreeetc.) are implemented.

+1
source

, .

ps -ejH
ps axjf
pstree $PID

ps pstree.

+1

All Articles