Linux – How to find all child processes

c++linuxprocess

In a Linux-based project that I am working on, I need to be able to find all of my child processes. It is not feasible to record every time one is started — they need to be found after the fact. This needs to be pure C, and I'd like to do it without reading /proc. Does anyone know how to do this?

Best Solution

It is usually entirely feasible to record child processes every time you start one. conveniently, the parent process is passed the pid value of the child process as the return value of the fork call which creates it.

As the man page says:

pid_t fork(void);

It would help if you could tell us why you think it isn't feasible.