[Haskell-cafe] Trouble with simple embedding of shell in haskell

Donn Cave donn at drizzle.com
Thu Sep 21 16:42:39 EDT 2006


On Thu, 21 Sep 2006, George Brewster wrote:

> I'm just tried writing a function to allow convenient embedding of shell
> commands, but I'm running into behavior I don't really understand 
> somewhere at the intersection of lazy evaluation, IO, and threading.

You may also find some unwelcome surprises in the area of pipes and
buffered I/O, that aren't specifically about Haskell.  Are you on a
UNIX platform?

I "rewrote" your function by removing both instances of forkIO, and
it worked about like I expected.  (The last one encounters an error
"broken pipe" when it tries to write "there" to the "echo hi" shell
process, because that process exits instead of reading from its input.)

I can't say whether you really need forkIO, or whether it's really going
to do what you need - not only do I not know enough about the thread
model, neither do I know what you're really trying to do.

	Donn Cave, donn at drizzle.com



More information about the Haskell-Cafe mailing list