FIX: #724 (tee complains if used in a process started by ghc)
authorSimon Marlow <simonmar@microsoft.com>
Mon, 7 May 2007 12:35:37 +0000 (12:35 +0000)
committerSimon Marlow <simonmar@microsoft.com>
Mon, 7 May 2007 12:35:37 +0000 (12:35 +0000)
commit57ea7ee5ac5f1851ce3cebf2244d48b9d475dc63
treea05882974d2125bfc695b44951a410e1b066486b
parent621b839753a122b5586aa87e51987d90a19478e4
FIX: #724 (tee complains if used in a process started by ghc)

Now, we only set O_NONBLOCK on file descriptors that we create
ourselves.  File descriptors that we inherit (stdin, stdout, stderr)
are kept in blocking mode.  The way we deal with this differs between
the threaded and non-threaded runtimes:

 - with -threaded, we just make a safe foreign call to read(), which
   may block, but this is ok.

 - without -threaded, we test the descriptor with select() before
   attempting any I/O.  This isn't completely safe - someone else
   might read the data between the select() and the read() - but it's
   a reasonable compromise and doesn't seem to measurably affect
   performance.
GHC/Handle.hs
GHC/IO.hs
GHC/IOBase.lhs
cbits/inputReady.c