Posix.runProcess

Manuel M. T. Chakravarty chak@cse.unsw.edu.au
Thu, 20 Sep 2001 00:43:14 +1000


I am doing this kind of stuff in the `Processes' module of

  http://www.cse.unsw.edu.au/~chak/haskell/ports/

I have not clue whether it runs on Windows or not, but would
be interested to know if you find out.

Manuel

-=-

George Russell <ger@tzi.de> wrote,

> 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
> 
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users@haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users