Closed snoyberg closed 9 years ago
In definition of stdout
etc, calls mkHandle
, calls getCharBuffer
, which does:
getCharBuffer :: IODevice dev => dev -> BufferState
-> IO (IORef CharBuffer, BufferMode)
getCharBuffer dev state = do
buffer <- newCharBuffer dEFAULT_CHAR_BUFFER_SIZE state
ioref <- newIORef buffer
is_tty <- IODevice.isTerminal dev
let buffer_mode
| is_tty = LineBuffering
| otherwise = BlockBuffering Nothing
return (ioref, buffer_mode)
Alternatively, don't use a TTY and change the above to check (say) for an environment variable.
(The confusing behaviour here is that when running executables we get block buffering.)
I implemented this a while back: https://github.com/fpco/ide-backend/commit/e9cdb91fe6ac5c4a436706efe7fd405ec17c6e8d
The goal would be to fix the line buffering behavior to match
runghc
or running a compiled executable. This isn't a strict requirement, but would be a nice enhancement. @dcoutts Let's discuss feasibility on Tuesday.