RE: "hSetBuffering stdin NoBuffering" messes up terminal

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.
It's deliberate, but (AFAIK) not for those reasons. The idea is so that "simple, stupid programs" do what the programmer expects (and saving the list from lots of "my program doesn't get any input until the user hits Return" questions).
If you were writing "stty" in Haskell, you would presumably use the PosixTTY functions directly.
GHC 6.2 will have slightly better behaviour in this regard. If the terminal settings are changed as a result of hSetBuffering, then they will be restored on exit. This still allows stty-type programs to be written, as long as you don't also call hSetBuffering on the same Handle. Cheers, Simon

On Tue, Oct 21, 2003 at 04:39:27PM +0100, Simon Marlow wrote:
It's deliberate, but (AFAIK) not for those reasons. The idea is so that "simple, stupid programs" do what the programmer expects (and saving the list from lots of "my program doesn't get any input until the user hits Return" questions).
If you were writing "stty" in Haskell, you would presumably use the PosixTTY functions directly.
GHC 6.2 will have slightly better behaviour in this regard. If the terminal settings are changed as a result of hSetBuffering, then they will be restored on exit. This still allows stty-type programs to be written, as long as you don't also call hSetBuffering on the same Handle.
Yay! That seems like precisely the right thing to do. :) -- David Roundy http://civet.berkeley.edu/droundy/

Simon Marlow wrote:
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.
It's deliberate, but (AFAIK) not for those reasons. The idea is so that "simple, stupid programs" do what the programmer expects (and saving the list from lots of "my program doesn't get any input until the user hits Return" questions).
If you were writing "stty" in Haskell, you would presumably use the PosixTTY functions directly.
GHC 6.2 will have slightly better behaviour in this regard. If the terminal settings are changed as a result of hSetBuffering, then they will be restored on exit. This still allows stty-type programs to be written, as long as you don't also call hSetBuffering on the same Handle.
Does this include the case where the program is suspended with SIGTSTP
(typically via the user pressing Ctrl-Z)?
What about resumption with SIGCONT? Even if the program doesn't
restore the terminal settings on SIGTSTP, something else (e.g. the
shell) may change them while the program is suspended, so they should
probably be refreshed upon SIGCONT.
--
Glynn Clements
participants (3)
-
David Roundy
-
Glynn Clements
-
Simon Marlow