How to restore terminal after curses program crashes?

Bill Campbell bill at camco.Celestial.COM
Tue Feb 19 05:56:40 AEST 1991


In <1991Feb13.133332.22320 at ousrvr.oulu.fi> clegg at tolsun.oulu.fi (Matthew Tran Clegg/VTT) writes:

>I've been working on a program that uses the curses package and
>cbreak mode.  Once in a while, a bug will cause the program to
>crash (for example, with a segmentation fault).  This completely
>unhinges the terminal.  It won't respond to anything anymore,
>except if I press ^C, then the csh prompt will be printed.

>(I've noticed sometimes that nethack will crash in this way too, but
>only when the game is better than any I've had in months -- a real bummer.)

>Does anyone know how to restore the terminal to a sane state?
>So far, the only thing that has worked for me is the power switch :-).

>Matthew Clegg
>clegg at tolsun.oulu.fi, February 13

I set an environment variable in my .login (.profile for /bin/sh
users)
	setenv NORMTTY			`stty -g`

This extracts the stty parameters in a form suitable as an
argument to stty so all I have to do is type:
	^Jstty $NORMTTY^J

where ^J is control-j.

This resets the terminal to your login state.

Bill
-- 
INTERNET:  bill at Celestial.COM   Bill Campbell; Celestial Software
UUCP:   ...!thebes!camco!bill   6641 East Mercer Way
             uunet!camco!bill   Mercer Island, WA 98040; (206) 947-5591



More information about the Comp.unix.programmer mailing list