Skip to content

tee complains if used in a process started by ghc

I have the following program:

import System

main = getArgs >>= system . head

i.e., a simple wrapper around the system command. I compile this using

ghc -o Sys --make Sys.hs

into a binary Sys. If I then call

./Sys "yes | head -n 20000000 | tee /dev/null"

the program quits with the message tee: write error. I tried on some machines, and on some I have to increase the argument to head, but at some point it always fails. Calling the shell command directly gives no error. However, calling

./Sys "yes | head -n 20000000" | tee /dev/null

(note the difference!) also fails.

This bug is a showstopper for my current project. In my program, I call other programs which internally employ tee for logging. Whenever there is a lot of screen output, there seems to be a good chance that my program fails.

I have no idea if this is a problem with tee or with ghc, but I couldn't yet reproduce it in any non-ghc context.

Andres Loeh

Trac metadata
Trac field Value
Version 6.4.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system Unknown
Architecture Unknown
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information