Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Printing ^C, ^D key presses at end of prompt when pressed



Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> writes:

> On Feb 4,  2:03am, Philippe Troin wrote:
> } Subject: Re: Printing ^C, ^D key presses at end of prompt when pressed
> }
> } bash-4.1$ stty echoctl
> } bash-4.1$ ^C
> } bash-4.1$ stty -echoctl
> } bash-4.1$                  <--- Ctrl-C pressed, no output.
> } 
> } No such luck in zsh (stty echoctl has no effect).
> 
> I actually did try this in bash before writing my original response.
> On the CentOS systems I have access to, echoctl makes no difference
> whatsoever to bash.  OTOH, they don't have bash4, so maybe this is
> something changed in readline at some point since bash3.  Or ...

The ^C are emitted by the kernel tty layer I believe.
The shell has nothing to do with it.
But you are right, I've just tested on a CentOS5 box, and echoctl has
no effect there.
 
> } No such luck in zsh (stty echoctl has no effect).
> } Coult it a spurious line redraw on ctrl-C (and others)?
> 
> Sorry, could you rephrase that?

I was suggesting that the sequence of events could be:

 1. Ctrl-C is pressed on the terminal

 2. Kernel tty layer sees it is the stty intr character, emits the ^C
    string to the tty, and send SIGINT to the foreground process group
    which would be zsh.

 3. Zsh catches SIGINT, then clears the line (that's where ^C would
    disappear), and redisplays the prompt.
  
> } Note how echoctl still works in zsh when using the read builtin or
> } just cat:
> } 
> } phil@air:~% stty echoctl
> } phil@air:~% read
> } ^C%
> } zsh: exit 1
> } phil@air:~% cat
> } ^C
> 
> On what may be a third hand, I don't get *that* either.  I have echoctl
> on all the time, but just to be doubly sure:
> 
> schaefer<511> STTY=echoctl cat 
> 
> schaefer<512> 

(I was not aware of the STTY special environment variable).
I think CentOS5's handling of tostop seems is broken or missing.

> Maybe there's yet another stty option getting involved here?  Even with
> bash3 I don't see the ^C when I interrupt cat.

It could be.  These are my full stty settings:

% stty -a
speed 38400 baud; rows 24; columns 80; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts
-ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
-iuclc -ixany imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke

I assume you do NOT have ttyctl is frozen mode:

% ttyctl
tty is not frozen

Phil.



Messages sorted by: Reverse Date, Date, Thread, Author