I need to monitor a process -- with a known PID -- and react to it either exiting for good, or writing into a file in a known subdirectory.
The file(s) may not initially exist. On BSD I would use kqueue
specifying the different things I want to be woken up for. But this program is for Linux.
I know, inotify can advise me of new files created or existing files opened/closed in a directory. But it will not tell me about the process exiting...
How do I watch for all of these events? Ideally, this would be done in shell, but I could compile a helper C-program, which the shell-script would call...