(To clarify: I used waitpid with WUNTRACED and the child's PID, being fork's return value, as the first parameter.)
I was wondering: is there a way for me to query for a child process's status regardless of any previous calls to wait-likes, without invoking external binaries like ps, or would I theoretically have to maintain some kind of state for each child myself?
To rephrase, just in case my phrasing is confusing: let's say I spawn a bunch of child processes, and I want to monitor which of those are still running, which have stopped (via SIGTSTP or SIGSTOP), and which have terminated. I could maintain state myself (for instance using a SIGCHLD handler), but I wanted to try using the OS to do this for me (I had the idea that this was indeed being done due to, for instance, ps displaying the status of each process in the system – so I wanted to access it). The first and last are simple to monitor using a kill(pid, 0) call, but the second – whether a process has stopped – seems to be trickier to query for. How might one go about this?