How to restore terminal after curses program crashes?
Brandon S. Allbery KB8JRR
allbery at NCoast.ORG
Sat Feb 23 16:05:59 AEST 1991
As quoted from <MEISSNER.91Feb17170024 at curley.osf.org> by meissner at osf.org (Michael Meissner):
+---------------
| In article <1991Feb17.164719.17328 at IRO.UMontreal.CA>
| babin at IRO.UMontreal.CA (Gilbert Babin) writes:
|
| | I have the same problem with AIX, but whenever I type a character (any one)
| | after the crash, the shell goes into an infinite loop.
| |
| | Any ideas on how to solve that on AIX?
|
| When debugging applications like the above, I typically invoke it via:
|
| nethack; reset_tty
|
| where reset_tty is my shell script to reset all terminal modes to
| normal values. For most people, you can do:
+---------------
telotech[05]:128 K$ cat /usr/lbin/oops
:
# oops - run program and restore terminal
#
g=`stty -g`
"$@"
status=$?
stty $g
tput sgr0
blockon
if [ $status -ne 0 ]; then
echo "oops: $1: exit $status" >&2
fi
telotech[05]:129 K$ cat pers/src/blockon.c
#include <fcntl.h>
main()
{
return fcntl(0, O_SETFL, (fcntl(0, F_GETFL, 0) & ~O_NDELAY)) == -1;
}
telotech[05]:130 K$ _
I find this invaluable for debugging: it restores the terminal after just
about anything (short of escape sequences that whack the terminal itself, i.e.
terminals that have escape sequences to change the baud rate).
Another trick I've used is to run a "script" variant I wrote which not only
restores the terminal afterward but logs the output. (The main variation is
that you can specify any program as the "shell".) That, however, doesn't
work on telotech because we don't have ptys (yet)....
++Brandon
--
Me: Brandon S. Allbery VHF/UHF: KB8JRR on 220, 2m, 440
Internet: allbery at NCoast.ORG Packet: KB8JRR @ WA8BXN
America OnLine: KB8JRR AMPR: KB8JRR.AmPR.ORG [44.70.4.88]
uunet!usenet.ins.cwru.edu!ncoast!allbery Delphi: ALLBERY
More information about the Comp.unix.programmer
mailing list