diff options
author | sof <unknown> | 1999-01-15 17:54:23 +0000 |
---|---|---|
committer | sof <unknown> | 1999-01-15 17:54:23 +0000 |
commit | b9bd8aedf924bd9396c2634792f5c472b36c3bf0 (patch) | |
tree | 51803079c75b0a650fb2a754bd5833202c86bbd6 /ghc/lib/std/cbits/flushFile.c | |
parent | fc3a5e13e8980632ca5b9ae589fab11818b4d425 (diff) | |
download | haskell-b9bd8aedf924bd9396c2634792f5c472b36c3bf0.tar.gz |
[project @ 1999-01-15 17:54:20 by sof]
Re-integrated mod. that seems to have been dropped on the
floor when new-rts moved back onto the main trunk. Here's
the commit msg. that was originally used:
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 a
write to h2 causes h2's buffer to overflow 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/cbits/flushFile.c')
-rw-r--r-- | ghc/lib/std/cbits/flushFile.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/ghc/lib/std/cbits/flushFile.c b/ghc/lib/std/cbits/flushFile.c index 7390b27ec2..d556d5ae1b 100644 --- a/ghc/lib/std/cbits/flushFile.c +++ b/ghc/lib/std/cbits/flushFile.c @@ -1,7 +1,7 @@ /* * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998 * - * $Id: flushFile.c,v 1.3 1998/12/02 13:27:32 simonm Exp $ + * $Id: flushFile.c,v 1.4 1999/01/15 17:54:23 sof Exp $ * * hFlush Runtime Support */ @@ -78,3 +78,21 @@ StgForeignPtr ptr; fo->bufWPtr=0; return 0; } + +void +flushConnectedBuf(ptr) +StgForeignPtr ptr; +{ + StgInt rc; + IOFileObject* fo = (IOFileObject*)ptr; + + /* if the stream is connected to an output stream, flush it. */ + if ( fo->connectedTo != NULL && fo->connectedTo->fd != -1 && + (fo->connectedTo->flags & FILEOBJ_WRITE) ) { + rc = flushBuffer((StgForeignPtr)fo->connectedTo); + } + /* Willfully ignore the return code for now. */ + return; +} + + |