Summary:ASTERISK-12714: asterisk console screws up terminal subtly when exited with ctrl-c with some shells
Reporter:Tzafrir Cohen (tzafrir)Labels:
Date Opened:2008-09-11 11:18:42Date Closed:2008-12-11 17:36:15.000-0600
Versions:Frequency of
Environment:Attachments:( 0) 20080911__bug13464.diff.txt
( 1) 20081110__bug13464.diff.txt

# asterisk -r
*** CTRL-C pressed here ***
*** CTRL-D pressed here***
zsh: do you wish to see all 1670 possibilities (835 lines)? n

This seems to be triggered by the combination of zsh
and asterisk. It is cleared by issuing 'stty sane'.

I tried comparing the output of 'stty -a' at the following:

1. Clear start ("sane")
2. Starting Asterisk from zsh and pressing ctrl-C ("zshbad")
3. Starting Asterisk from bash and pressing ctrl-C ("bashbad").

No noticable differences between "sane" and "bashbad". The differences
between "sane" and "zshbad" are:

sane zshbad
----    ------
eof     ^D      <undef>
rprnt   ^R      <undef>
werase  ^W      <undef>
lnext   ^V      <undef>
     -inlcr    inlcr
     iexten -iexten
     echok     -echok

Tested with recent trunk (r142359) and the following shells on a Debian Lenny system:

bash                  3.2-4
busybox-static        1:1.10.2-1
dash                  0.5.4-11
posh                  0.6.13
zsh                   4.3.6-6

posh and bash work well. zsh, dash and busybox ash mis-behave: leave
'eof' undefined. With dash and busybox ash, after pressing ctrl-C you
can no longer write to the terminal (until a 'clear' or 'stty sane')

Workaround: run 'stty sane' on the affected shells after such a ctrl-C.
Comments:By: Tilghman Lesher (tilghman) 2008-09-11 13:34:01

This should probably fix it.  Patch against 1.4.

By: Tzafrir Cohen (tzafrir) 2008-09-11 14:24:21

Doesn't. Same as before. At least with zsh, on 1.4 r142358 .

By: David Woolley (davidw) 2008-09-12 05:48:45

There is another problem with failing to recover properly when interrupted by a signal.  If you use ^Z (normal binding for SIGTSTP) and then resume, one gets cursor keys echoed rather than selecting/editing the historic command line, even though the selection the action actually works on the internal copy of the line.

By: Tilghman Lesher (tilghman) 2008-11-10 16:05:25.000-0600

New patch uploaded.  Needs further testing.

By: Leif Madsen (lmadsen) 2008-12-11 14:30:49.000-0600

While this is the first time I have used zsh (or rather anything other than bash), I was able to successfully reproduce the issue using the ctrl-C and ctrl-D commands. I saw that tzafrir was seeing.

After installing the latest patch, it seems to have resolved the issue from what I can see. Someone more experiences with zsh (and others) should probably do some more testing though.

By: Digium Subversion (svnbot) 2008-12-11 17:36:14.000-0600

Repository: asterisk
Revision: 163383

U   branches/1.4/main/asterisk.c

r163383 | tilghman | 2008-12-11 17:36:14 -0600 (Thu, 11 Dec 2008) | 9 lines

When a Ctrl-C or Ctrl-D ends a remote console, on certain shells, the terminal
is messed up.  By intercepting those events with a signal handler in the remote
console, we can avoid those issues.
(closes issue ASTERISK-12714)
Reported by: tzafrir
      20081110__bug13464.diff.txt uploaded by Corydon76 (license 14)
Tested by: blitzrage