wait(2)
Marcin 'Qrczak' Kowalczyk
qrczak@knm.org.pl
26 Jul 2001 19:38:42 GMT
Thu, 26 Jul 2001 16:44:57 +0200, George Russell <ger@tzi.de> pisze:
> Is there a way in Glasgow Haskell to get a thread to wait on a
> child process in the same way as the Posix function wait(), and
> get the termination status of the child?
There is no easy way: all Haskell's thread run in the same process
and wait() blocks the whole process.
The only (or the only portable) way is to call wait() with WNOHANG
repeatedly in a thread and threadDelay for a short period of time
between calls.
This is what OCaml runtime does. It provides waiting for a process
as a threading primitive. It accounts for waiting in its select()
loop in the scheduler.
--
__("< Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/
\__/
^^ SYGNATURA ZASTĘPCZA
QRCZAK