In my Ruby app I'm trying to come up with a foolproof and cross-platform way of ensuring that a parent's child processes get killed when the parent does (see this question).
One possibility that I'm exploring is the idea of spawning a separate process that watches the parent and kills the child process if the parent dies. I've already come up with an effective way of letting this monitoring process know when the parent dies, but now I need a way for it to watch the child process so the monitoring process can exit if the child dies before the parent. Note that the "child process" is a child of the monitoring process's parent, not the monitoring process itself.
So what I need to know is this: Given the PID of some process, how can I check if that process is still running (or better yet, be notified when it dies) in a way that is cross-platform? (E.g. works on both Linux and Windows.)