0

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.

fgsfds
  • 56
  • 1
  • 4
  • Note that `waitpid` also doesn't do what you want for even a single process. It only waits for child processes. – kaylum Feb 10 '17 at 23:13
  • Thanks, I didn't know that. I was using an abstraction given by a Python library that somehow is able to wait on a non-child to exit. I think I'm going to be taking the netlink-based approach suggested in the question this was marked as a dupe of. – fgsfds Feb 11 '17 at 00:32

0 Answers0