Re: hat-trail fails to restore tty state

Malcolm Wallace <[email protected]> Thu, 1 Jul 2004 17:37:29 +0100
Newsgroups gmane.comp.lang.haskell.hat
Organization Dept of Computer Science, University of York
Message-ID <[email protected]>
Fergus Henderson <[email protected]> writes:

> > > Also, hat-trail failed to properly restore the tty state after ":q".
> 
> I am using "Konsole" (specifically, Konsole 1.3.2 with KDE 3.2.2).
> But the same problem also happens if I use "xterm".

Aha!  Terminal resetting works fine with all of the following: xterm,
konsole, gnome-terminal, provided you are using ghc-5.  But it breaks
on all of the above if you use ghc-6.  So there is something decidedly
odd going on.  Here is the relevant code in hat-trail:

    resetSystem :: State -> IO ()
    resetSystem state = do
        putStr (enableScrollRegion 1 (height state))
        putStr (goto 1 (height state))
        System.system ("stty icanon echo")
        return ()

which looks fine to me.  Indeed, here is a mini-test program that
actually works in ghc-6.2.1 without breaking the terminal settings:

    import System; import Char; import IO
    main = do hSetBuffering stdin NoBuffering
              hSetBuffering stdout NoBuffering
              system ("stty -icanon -echo")
              getChars
              system ("stty icanon echo")
              putStrLn "Done"
    getChars = do c <- getChar
                  putChar (toUpper c)
                  if c=='q' then return () else getChars

I'm inclined to report this as a bug in ghc, even though I don't seem
to be able to cut down the problem to a simple test case.

Regards,
    Malcolm