[news.software.nn] resetting terminal after nn dumps core

epstein@sunc2.cs.uiuc.edu (Milt Epstein) (06/18/91)

Recently I posted a note asking how I could reset my terminal after nn
dumped core.  I got several responses and thought I'd post a summary
and say thanks to all who responded.

First of all, the reason the terminal seems to be "stuck" (i.e. not
echoing or responding), was explained very well by Kristian Koehntopp
(kris@tpki.toppoint.de):

>nn puts your tty into cbreak or raw-mode with no echo. Your CR-LF is no
>longer translated into the unix LF and your characters are no longer echoed
>back to you. nn needs to run in cbreak mode, because otherwise you had to
>press return after each command.

So, when nn dumps core and exits less than gracefully, it is not able
to restore the proper terminal mode.  And therefore, as david nugent
<david@csource.oz.au> points out:

>^J works just fine of the linefeed key, but ENTER/RETURN/^M doesn't.

So, the solution is to give the command to restore appropriate
terminal settings, prefixed and suffixed by ^J's (the prefix one to
clear the buffer just in case, and the suffix one because CR won't
work, as just pointed out.)

So, the question is then what command to give to restore appropriate
terminal settings.  Most responders suggested some variation of stty,
including:

    stty onlcr icrnl echo echoe [From: wolf@netcom.com (Buckskin Tech.)]
    stty sane echoe echok [From: david nugent <david@csource.oz.au>]
    stty sane, then stty echoe [From: kris@tpki.toppoint.de (Kristian Koehntopp)]

As all of these people pointed out, these may not completely restore
your terminal settings -- that would depend on exactly how it was set
previously -- so you may have to do some further adjustments with
stty.  In particular, on my system, after doing 'stty sane', I got a
prompt and things echoed, but things weren't 100% right -- for
example, when I did 'ls', the listing was all compressed on one line
with lots of beeps.  Actually, I couldn't figure out how to fix this,
but I didn't need to, since I had received another suggestion from
David Hull (david@wilbur.coyote.trw.com) to use 'reset' (instead of
stty).

So, to sum up, here was David Hull's (who happens to be the news admin
for my site, but is now enjoying the summer in California) reply:

>Almost certainly the terminal is stuck in raw mode.  Type "^jreset^j",
>where ^j is control-j.  Note that ^j is the real newline character.
>In cbreak mode, carriage return gets mapped to newline, but not so in
>raw mode.

(And BTW, I had been trying 'reset' before I posted my note -- the
problem was I wasn't using ^J's.)

And finally, thanks to all who responded::

     wolf@netcom.com (Buckskin Tech.)
     david nugent <david@csource.oz.au>
     kris@tpki.toppoint.de (Kristian Koehntopp)
     david@wilbur.coyote.trw.com (David Hull)

-- 
Milt Epstein
Department of Computer Science
University of Illinois
epstein@cs.uiuc.edu