"hSetBuffering stdin NoBuffering" messes up terminal

Alastair Reid alastair at reid-consulting-uk.ltd.uk
Tue Oct 14 15:34:10 EDT 2003


On Tuesday 14 October 2003 2:11 pm, David Roundy wrote:
> On my terminal (aterm), calling
>
> hSetBuffering stdin NoBuffering
>
> within my program messes up the terminal settings somehow, [...]

If I understand recent changes correctly, this is a deliberate decision.  The 
idea is that if you wanted to write a program like 'stty' in Haskell, you'd 
be very disappointed if the terminal settings got switched back the moment 
your Haskell program terminated.

Given this (reasonable) change, it might be worth providing an additional 
function:

  hWithBuffering :: Handle -> BufferMode -> IO a -> IO a

which sets the buffering mode back when it finishes.

(There's a bunch of alternative designs possible here - this has the virtue of 
being simple.)

--
Alastair Reid    www.haskell-consulting.com



More information about the Haskell-Cafe mailing list