[Haskell-cafe] How to fork a process?

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Thu Jun 25 05:09:46 EDT 2009

On Jun 25, 2009, at 05:01 , Magicloud Magiclouds wrote:
>  In many language, both thread and process are supported. But in
> haskell's document, the only thing I could find called fork is to make
> a thread. So how to fork the program itself, like fork () in C?

Internal threads can be done reasonably portably (well, assuming you  
don't look at the internals of the runtime :) but fork() is specific  
to POSIX/Unix-like systems.  (I'm told you can emulate it on Windows  
but it's neither fast nor easy; on most non-Unixlike systems the  
native operation is to spawn a process running a new executable, and  
cloning the current process is unusual at best.)

As such, forkProcess lives in System.Posix.Process, along with  
executeFile (overlaying the current process's executable image is  
likewise a Unixism) and other operations specific to the POSIX/Unix- 
like process model.

brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090625/8929510a/PGP.bin

More information about the Haskell-Cafe mailing list