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

Re: zsh, ctrl-something, and recent kernels



Brian K. White wrote:
First off, "recent kernels" is meaningless.
Meaningless no, no specify at this point in the message, yes.
I have very recent FreeBSD and SCO Open Server kernels that do not display any such problem with any version of zsh.
Ok, that is useful information.

Secondly, "ctrl-c" is likewise meaningless, at least until we establish that the kernel in question must be Linux, and that you haven't used stty to change the interrupt key from it'sdefault.
I disagree that ctrl-c is meaningless. Plus as the topic and the beginning of the message suggest, I have problems with more than just ctrl-c. I do mention ctrl-z in the original message. I just use ctrl-c as my example, since it was the one I ran into first, and is the most commonly used.
Thirdly, unlike the 2 points above which can be deduced because eventually at the end you mentioned RedHat, another important fact can't be deduced, which is what kind of terminal (or trail of terminals) is this failure appearing on? The console? xterm? rxvt/gnometerm/other xterm-alike? one of the bezillion windows terminal emulators? and the communication layer? ssh? telnet? rlogin? serial? local socket? X over tcp-ip? Vnc? Several of the above thus eliminating any one as the culprit?

Before the end I do mention versions of the Linux kernel that are very likely only Linux kernel versions and not any other OS's kernel versions. If you had read the bug report I linked to, you would have found I mention the console, and more details.
Using all three of putty over ssh, the console, and rxvt, on all three of freebsd, sco open server, and suse 10.0 (linux 2.6.13 smp kernel) (9 different tests), I do not see a problem with the break key (no mater what I set "intr" to, including ctrl-c)

Not surprised I have never seen it before with Linux, and I have been using zsh for years with it.
So, it sounds like a tty driver bug in recent linux kernels to me, not anything even within zsh's possibility to control or work around, let alone be obligatd to. It's the terminals job to read the physical keyboard and keep track of such things as the state of the various mode shifting meta keys and translate some actions into other things. It's the tty drivers job to recognize and interpret some sequences and translate them into other things or otherwise act upon them, while still being considered input. It's the kernels job or the server side communication daemon (sshd, telnetd, etc...) 's job to send signals to the child processes like zsh. zsh merely has to trap the signal, which if it does on any platform then it's doing it. If a recent linux kernel changed to cause this, then that kernel changed away from doing the right thing to doing the wrong thing and it's the kernel that needs to change back.

Maybe, but the goal is to figure out exactly why, and who should fix it. In my mind the evidence is pointing to zsh, hence why I asked on this mailing list.

Try setting intr to a plain single character like ~, or one that doesn't need any meta keys, not even the shift key, like . or , or ' or ` (obviously once you do that you have to be careful to avoid commands that need the character you chose) and use cat -v (why I didn't suggest - as a new break key) and see what happens when you press ctrl-c [enter] once, twice, three times. You should see ^C for each time you press ctrl-c, but you don't see anything until you press Enter, then you see everything that happenes since the last Enter. (or ctrl-m for that matter!) You could use ctrl-v followed by ctrl-c right on the zsh command line, but it's stupid to try and use a ctrl key it to diagnose a problem that might be with ctrl keys in general. Maybe ctrl-v also only works once. Or maybe ctrl-anything, such that the ctrl-v would work, and then the immediately following ctrl-c doesn't. The stty change only lives for the duration of that session and only effects that session, it's completely safe.
After setting intr to ~ it behaves as expected. I can run cat -v and see ^C over and over. I see the same if I change susp, ^Z, to ~.

If you don't see ^C the 2nd or 3rd times, then something is wrong way before zsh can do anything about it. If you do see a ^C for every time you press it then it's a little more interesting. In that case, start a new session without running stty, press ctrl-c until it stops working, then run stty intr "^c", and then press ctrl-c again. Does the stty reset the ctrl-c so that it works one more time?

I do see ^C the 2nd and 2rd times. Using stty intr "^c" doesn't help. It is already set to ^c, and it just stays the same.
Start another new session and run "stty -a >stty.a"
Then press ctrl-c until it stops working
Then run stty -a >stty.b
Then diff -u stty.a stty.b
Do stty.a and stty.b differ at all?

No difference
Do the same test under bash and ksh. (if ctrl-c never stops working n bash or ksh, then just press it however many times it takes for it to stop working in zsh.)
Do stty.a & .b differ under zsh but not under other shells?

Try running bash from within bash. Does ctrl-c fail in the child bash but not in the parent? Try running bash as a child under zsh. Does the child-of-zsh-bash still work? Try setting a users login shell to zsh (as opposed to running zsh manually after logging in to a login shell of bash). Does ctrl-c still fail then? Try other shells besides just bash & zsh. try ksh (or pdksh) ash, csh etc... There may be a quirk where something is wrong but just bash happens to work anyway. Like maybe the wrong signal is being sent after the first time, but maybe bash just happens to trap that other signal too, and just happens to treat it similarly to break (ctrl-c).

I didn't try bash in bash. But bash directly works perfectly, zsh obviously doesn't, bash in zsh before the problem occurs in zsh works, and bash in zsh after the problems appears in zsh doesn't work.
For that matter, you could do this:
n=0 ;until [ $n -gt 15 ] ;do trap "echo $n" $n ;((n++)) ;done
Then press ctrl-c a few times.
On a properly working terminal you should see "2" every time you press "break" ie ctrl-c in your case. If you stop getting new 2's, or start getting something else, then the os or possibly the server communication daemon is broken.
Try the same thing in bash. ksh.
Try the same thing under different server daemons (ie: telnet, rlogin, directly at the console, an xterm window, etc.. instead of opensshd)

In zsh the ctrl-c to print a 2 works until I run a command like ls. Then it stops printing 2s until I repeat the n=0... again. With bash it works even after running ls.


I tried most of my testing on the console, as in tty1. I repeated some of the tests in a ssh connection from my laptop to the desktop with the problem using putty. I saw the exact same results I saw on the console. The ssh connection use a pts, like pts/8. I have also tried some of this in the past inside gnome-terminal with at least similar results, again a pts.

I did test more than ctrl-c. ctrl-z doesn't work from what appears to be the start. I login, I run top, I try ctrl-z, and get nothing. In bash it works just fine.
Brian, who is annoyed by people who forget that the universe is not linux.
I didn't specify exactly, but I gave plenty of big hints I was talking only about Linux. But I understand your point.
At least by using zsh you automatically avoid the similar annoyance of people who think all "sh" everywhere is bash and write scripts accordingly.

I think it is bad that many don't know anything but bash exists. As for scripts, bash is at least virtually the universal Linux default shell, and there are too many shell differences to try to be shell agnostic with all scripts.



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