RE: Calling an external command from a Haskell program

I've cc-ed to the libraries list - perhaps someone there could comment on the state of portable replacements for Posix functionality, especially for popen and friends? I seem to recall a very promising discussion about portable and flexible ways to start subprocesses a while ago - has that led to any concrete libraries?
Regarding processes, I made this proposal: http://www.haskell.org/pipermail/libraries/2003-May/000958.html but didn't get any further. The sticking point is that GHC needs a thread-safe wait() implementation, which means some hacking in the scheduler (there isn't even a good way to do this portably, because select() doesn't let you wait for process termination). Cheers, Simon

On Tue, Oct 21, 2003 at 02:09:50PM +0100, Simon Marlow wrote:
http://www.haskell.org/pipermail/libraries/2003-May/000958.html
but didn't get any further. The sticking point is that GHC needs a thread-safe wait() implementation, which means some hacking in the scheduler (there isn't even a good way to do this portably, because select() doesn't let you wait for process termination).
recently, I had need for a non-blocking System.system which interacted well with concurrency and came up with the following 2 solutions: 1. trap SIGCHLD, once you get a a SIGCHLD you know wait() won't block. unfortunatly there isn't a way to get at the siginfo_t with the standard haskell libraries, but this can be worked around. 2. use pipe(2) or socketpair(2), fork (real fork, not forkIO), forked process runs the program and write(2)s the processstatus to its end of the pipe. the parent process does a Control.Concurrent.threadWaitRead on it's end of the pipe, reads the exit status and returns it like normal. I never got around to implementing either but I can't think of any reason why they wouldn't work. perhaps we need a concurrency status page for library calls which we know are concurrentsafe and ones we need to fix. (like System.system) John -- --------------------------------------------------------------------------- John Meacham - California Institute of Technology, Alum. - john@foo.net ---------------------------------------------------------------------------

In local.libraries, you wrote:
The sticking point is that GHC needs a thread-safe wait() implementation, which means some hacking in the scheduler (there isn't even a good way to do this portably, because select() doesn't let you wait for process termination).
*mumbl* libevent *mumbl* -- http://www-i2.informatik.rwth-aachen.de/stolz/ *** PGP *** S/MIME rage against the finite state machine
participants (3)
-
John Meacham
-
Simon Marlow
-
Volker Stolz