[Haskell-cafe] Fork & execve

Donn Cave donn at drizzle.com
Tue Jul 5 15:28:04 EDT 2005

On Tue, 5 Jul 2005, yin wrote:
> Is there some way how to fork a process in haskell? And excuting an
> another proces, waiting until it exit and colecting his stdout?

Yes, but it depends on
 -- your Haskell environment (ghc?)
 -- your platform (UNIX?)
If it's ghc and UNIX, see

Or if you would rather use low level POSIX functions directly, see
the Posix.IO and Posix.Process pages.  The effect of these functions
should be as described in the respective man pages for the C functions
(though with a few gratuitous API modifications like a [1..n] argv where
the C function takes [0..n].)

For the "Process" vs. "Command" distinction, "Command" uses the UNIX
shell to interpret a command, where "Process" would execute it directly.
If you are going to compute the command parameters, it's much easier to
use the "Process" version, than to check the shell command input data for
shell punctuation that would have unintended results.

If you're on another platform or using another Haskell implementation,
it still might be worth a try, I just haven't tried it myself.

	Donn Cave, donn at drizzle.com

More information about the Haskell-Cafe mailing list