in reply to Monitoring child threads

weismat:

I'd suggest making a signal handler for SIGCHLD, then your handler could examine the data structures owned by the child and look for an error state. So your child can set its state to "IDLE" until it gets a job, then set its state to "WORKING", and then "IDLE" when the job ends. Finally, set the state to "DONE" before terminating normally. If you get a SIGCHLD and the child isn't in "DONE" state, it's an error.

I'd suggest ignoring this node, as it's completely wrong, as indicated by TOD below...

...roboticus

Replies are listed 'Best First'.
Re^2: Monitoring child threads
by weismat (Friar) on Jan 24, 2008 at 13:26 UTC
    Great suggestion, but unfortunately I am running this program either on Linux or Windows - I guess I could use a different signal for Linux, but it will not work for Windows.
      weismat:

      OK, here's what I'd suggest... ;^)

      Create a set of shared variables to maintain the child processes state and time of last update (like a watchdog). Then periodically wake up your main loop, and check for any thread whose last update time is too long whose state is not "DONE"....

      ...roboticus