[Hat] Re: hat-trail fails to restore tty state

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Thu Jul 1 12:37:29 EDT 2004


Fergus Henderson <fjh007 at galois.com> 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


More information about the Hat mailing list