Path: utzoo!mnetor!tmsoft!torsqnt!lethe!yunexus!ists!helios.physics.utoronto.ca!news-server.csri.toronto.edu!bonnie.concordia.ca!nstn.ns.ca!news.cs.indiana.edu!news.nd.edu!spool.mu.edu!sdd.hp.com!usc!apple!agate!usenet.ins.cwru.edu!ncoast!allbery From: allbery@NCoast.ORG (Brandon S. Allbery KB8JRR) Newsgroups: comp.unix.programmer Subject: Re: How to restore terminal after curses program crashes? Message-ID: <1991Feb23.050559.14749@NCoast.ORG> Date: 23 Feb 91 05:05:59 GMT References: <28768:Feb1714:55:3591@kramden.acf.nyu.edu> <1991Feb17.164719.17328@IRO.UMontreal.CA> Reply-To: allbery@ncoast.ORG (Brandon S. Allbery KB8JRR) Followup-To: comp.unix.programmer Organization: North Coast Public Access Un*x (ncoast) Lines: 56 As quoted from by meissner@osf.org (Michael Meissner): +--------------- | In article <1991Feb17.164719.17328@IRO.UMontreal.CA> | babin@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 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@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 Brought to you by Super Global Mega Corp .com