
Volker Stolz wrote:
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.
Yes, but I get the feeling this aint gonna work on Windows, which is my whole reason for wanting to switch to Posix.runProcess. Could something like this be implemented on Windows?
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.
Yes, this would quite satisfactory. Then I could fork off a GHC thread to do takeMVar.
Of course another solution would be to implement all this inside of runProcess, so you *would* block until runProcess returns, unless you use forkIO.
Yuck. I'm afraid I would also like to be able to kill the process launched by runProcess too, if possible. Is this within Windows' capabilities? George