How would I even go about forking a child process using Haskell in the first place?

Also, if pipes are an obvious solution to the data sharing question - is there any other way to do it besides using pipes? I'm familiar with the use of shared memory segments in C (the shmget, *shmat, shmdt and shmctl functions). Could Haskell be able to imitate this? If so, how?

I'd be very grateful for any help you could spare.

I must admit I'm very much new to functional programming languages, even more so when it comes to Haskell. So forgive me (and please correct me) if I said something silly.

Was it helpful?


Better yet, use Software Transactional Memory - that is, TVars and TChannels.

Will recommend the same book, different chapter:

Here is a good small example of this technique in action:


The OP asked about communicating with a subprocess, not a thread. For that, pipes are a perfectly fine way of doing it. You can also call the C library function directly from Haskell if you want to, although that could get tricky.

This question has a better answer over here: Is there some standard Haskell library dealing with process communication?

use MVars or Channels. See chapter 24 of RealWorld Haskell:

If you want to actually fork a process, Unix style, you need to use forkProcess as given by

In this case, MVars and TVars do not do interprocess communication, so you cannot use them to do IPC. All standard techniques for IPC (pipes, sockets, etc) still work. If you want something more high-level, check out Cloud Haskell

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow