How to find all child processes?

c, linux, process

Solution

I find your comment that it is not feasible to record the creation of processes to be odd, but if you really can't (possibly because you don't know how many will be created and don't want to have to keep `realloc`ing memory), then I would probably open all of the files that match the glob `/proc/[1-9]*/status` and look for the line that says `PPid: <num>` where `<num>` was my process id.

Problem

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?

Original source