multiple processes and threads

Dean Herington heringto@cs.unc.edu
Mon, 25 Feb 2002 12:46:29 -0500


I have an application that uses multiple processes and multiple threads
together.  What's the best way to detect child process terminations?

The initial thread in the inital process serves as driver of the
application.  It creates child processes and threads to carry out
portions of the computation.  A natural way to have the driver detect
termination of these child processes and threads would be to have the
driver "listen" on a single MVar to which termination notices are
"posted".  Child threads would simply post their termination notices
directly.  For child processes, I'd like to have a single thread in the
initial process execute (getAnyProcessStatus True False) repeatedly,
posting a termination notice each time such a call returns.  However,
with the current implementation of Concurrent Haskell, when the thread
pends on the getAnyProcessStatus call, the entire initial process
pends.  The best solution I've come up with so far, which is
unsatisfying, is to have this thread poll periodically (that is, loop
over (getAnyProcessStatus False False) and (threadDelay)).  Is there a
better way?

Dean Herington