
Krzysztof Kościuszkiewicz wrote:
This works for files, but "randomly" fails when stdin is connected to a pipe (pstops complains that it can't seek input).
GHC's file handles are backed by non-blocking file descriptors. The child process run by executeFile inherits the stdin, stdout and stderr file descriptors of your Haskell process, so they're unexpectedly (from its perspective) in non-blocking mode. Due to POSIX sharing semantics, you can't simply switch those file descriptors to blocking in the child, because they'll then become blocking in the parent, too. Anything involving sharing file descriptors between processes becomes similarly broken if the GHC runtime starts using a file descriptor as a Handle. You're not the only one to be surprised by this behaviour, but unfortunately it's not trivial to work around. Simon Marlow was going to look into this problem a few months ago, but I don't know if he's had a chance to.