How to restore terminal after curses program crashes?

Art Neilson art at pilikia.pegasus.com
Sun Feb 17 07:58:08 AEST 1991


In article <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 :-).

The best way to handle this is to trap signals in the C program which
uses curses and have the signal handler call endwin() prior to exiting.
-- 
Arthur W. Neilson III		| INET: art at pilikia.pegasus.com
Bank of Hawaii Tech Support	| UUCP: uunet!ucsd!nosc!pegasus!pilikia!art



More information about the Comp.unix.programmer mailing list