diff options
author | sof <unknown> | 1998-11-23 15:44:25 +0000 |
---|---|---|
committer | sof <unknown> | 1998-11-23 15:44:25 +0000 |
commit | bbe9c55569ffa1ea660a02d7349afb4ba659072d (patch) | |
tree | 7b8e6b964012cdda16a1bdf2b092719cc0d04af7 /ghc/lib/std/IO.lhs | |
parent | 9a13d5c84f7467ea29fc7e50b7257585e9c1cee7 (diff) | |
download | haskell-bbe9c55569ffa1ea660a02d7349afb4ba659072d.tar.gz |
[project @ 1998-11-23 15:44:21 by sof]
Extend hConnectTo to also allow output handles to be connected, i.e.,
h1 <- openFile "foo" WriteMode
h2 <- openFile "bar" WriteMode
hConnectTo h1 h2
will cause h1's buffer to be flushed when h2's buffer overflows
(and it is just about to be flushed.) The implementation is currently
not as lazy as that, it flushes h1's buffer regardless of whether h2's
buffer overflows or not.
This is used to connect 'stderr' and 'stdout', i.e., output on
'stderr' will now cause 'stdout' output to (first) be flushed.
Diffstat (limited to 'ghc/lib/std/IO.lhs')
-rw-r--r-- | ghc/lib/std/IO.lhs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/ghc/lib/std/IO.lhs b/ghc/lib/std/IO.lhs index 5c8c9fb0b1..4c40d943d1 100644 --- a/ghc/lib/std/IO.lhs +++ b/ghc/lib/std/IO.lhs @@ -329,6 +329,7 @@ hPutChar :: Handle -> Char -> IO () hPutChar handle c = do handle_ <- wantWriteableHandle "hPutChar" handle let fo = haFO__ handle_ + flushConnectedHandle fo rc <- mayBlock fo (_ccall_ filePutc fo c) -- ConcHask: UNSAFE, may block. writeHandle handle handle_ if rc == 0 @@ -345,6 +346,7 @@ hPutStr :: Handle -> String -> IO () hPutStr handle str = do handle_ <- wantWriteableHandle "hPutStr" handle let fo = haFO__ handle_ + flushConnectedHandle fo case haBufferMode__ handle_ of LineBuffering -> do buf <- _ccall_ getWriteableBuf fo |