Xref: utzoo comp.unix.programmer:1072 comp.unix.questions:28668 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!spool.mu.edu!think.com!mintaka!bloom-picayune.mit.edu!athena.mit.edu!jik From: jik@athena.mit.edu (Jonathan I. Kamens) Newsgroups: comp.unix.programmer,comp.unix.questions Subject: Re: How to restore terminal after curses program crashes? Keywords: curses,cbreak,terminal Message-ID: <1991Feb13.233750.13206@athena.mit.edu> Date: 13 Feb 91 23:37:50 GMT References: <1991Feb13.133332.22320@ousrvr.oulu.fi> Sender: news@athena.mit.edu (News system) Organization: Massachusetts Institute of Technology Lines: 26 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@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8085 Home: 617-782-0710