I have a set of PIDs I want to monitor; I would like to be notified if any of these processes die. I know how to monitor one process at a time with waitpid
, however I am not aware of any way to wait for several processes simultaneously (unless they are my children, in which case I can use wait
). I've tried using inotify
on /proc
, however it turns out that procfs doesn't behave the normal way a normal filesystem does. Is there any way to monitor several processes for exit, short of running multiple monitoring threads or polling each PID at some interval?
In the end, I'll be implementing this in Python, but really the approach is language-agnostic and most of this low-level stuff will be most familiar to C programmers. Therefore, I've tagged this question with both languages.