Wed, 19 Sep 2001 12:48:05 +0200
In local.glasgow-haskell-users, you wrote:
> I think Posix.runProcess should give access to the eventual exit state of
> the process, if any. Two possible ways:
> (1) Change its result to IO (IO ExitCode), the inner action being something
> that waits for the process to complete (without blocking all other threads!)
> and returns the ExitCode.
> (Even better would be to make the result just IO ExitCode but this might
> be too incompatible for people who rely on runProcess returning at once.)
It seems kind of hard to get the exitcode without calling wait() and thus
blocking all threads. A solution I'm currently using is to install a SIGCHLD
handler which grabs the exit-code of the/a forked process with
Posix.getAnyProcessStatus. You could
store these results in a mutable global object (MVar, or MVar (FiniteMap ..))
and then retrieve the result.
It would be possible to have runProcess to return (MVar ExitCode) *immediately*
(so it doesn't break things), and only when you read the MVar you get (lightweight)
suspended until the process exits.
Of course another solution would be to implement all this inside of runProcess,
so you *would* block until runProcess returns, unless you use forkIO.
Volker Stolz * email@example.com * PGP + S/MIME