How to restore terminal after curses program crashes?
Jonathan I. Kamens
jik at athena.mit.edu
Thu Feb 14 10:37:50 AEST 1991
Your program should keep track of when curses is activated and when it
isn't. It should then install signal handlers for all of the fatal signals,
and when it gets such a signal, restore the tty modes, remove the signal
handler, and send itself the signal again (to get a coredump, which you
presumably want for debugging).
Actually, you shyould remove your signal handlers before calling the curses
function to restore the tty modes. That way, if curses has somehow gotten
confused and manages to generate another signal while restoring the modes,
you'll get a coredump instead of an infinite loop.
(Yes, I know it's considered bad form to call complicated functions like
curses functions inside signal handlers. But in this case, it's considerd
even worse form to leave the terminal in a screwed up state, so I think it's
worth trying.)
As for recovering from screwed up terminal settings -- someone else
suggested using tset, and that will probably work; you can also try just
typing "reset," which should clear things up a little bit.
--
Jonathan Kamens USnail:
MIT Project Athena 11 Ashford Terrace
jik at Athena.MIT.EDU Allston, MA 02134
Office: 617-253-8085 Home: 617-782-0710
More information about the Comp.unix.questions
mailing list