logo       

Re: ghc-6 messing with terminal settings?: msg#00002

lang.haskell.glasgow.bugs

Subject: Re: ghc-6 messing with terminal settings?

"Simon Marlow" <simonmar@xxxxxxxxxxxxx> writes:

> > It would appear that ghc-6 is being careful to save the current state
> > of the terminal at the point of hSetBuffering, and to restore it on
> > exit, something ghc-5 did not do. But paradoxically, this "safer"
> > choice caused things to mess up, instead of getting better!
>
> Your diagnosis is spot on.
>
> I suggest you just remove the 'stty' commands in that code (which don't
> work on Windows, incedentally), and it will do what you want.

But such a solution will not work in nhc98 or Hugs I suspect. The '98
Report does not AFAIK specify any particular terminal behaviour for
programs using hSetBuffering, so ghc goes beyond the standard here.
Perhaps all the compilers should follow suit, but that is a discussion
we haven't had yet.

> Better even: GHC will save and restore the terminal settings,
> whereas your program always sets the terminal to icanon/echo on exit.

Yes, calling stty was always a bit of a hack anyway. But it
highlights the real lack, which is a a portable library in Haskell
(System.Console.Term?) to give explicit control over these matters.
Alastair Reid suggests something like

data TTYState = .....
getTTYState :: IO TTYState
setTTYState :: TTYState -> IO ()

Regards,
Malcolm


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise