[Techtalk] Ctrl-C handling and stty
akkana at shallowsky.com
Mon Aug 25 17:14:21 UTC 2014
I have a weird problem I'm having trouble tracking down:
something is messing with my terminal settings, specifically Ctrl-C.
But I'm not sure what it is, because by the time I notice it
(because I need to interrupt a program by hitting Ctrl-C, and
it doesn't work so I have to open another window and use pkill),
it's too late to figure out what caused it.
Typing reset fixes the problem, but I want to find out why it's
happening so I can prevent it.
When it happens, it's always in a terminal where I've been doing
a lot of three things: git, meld (which I use for git difftool),
and ncftp (because I'm helping out with a website on a host that
only supports ftp, not ssh).
Being an old unix fogey, I assumed the difference was stty.
stty used to have modes like raw, cooked and cbreak that affected
whether characters like ^C worked.
So I decided I'd set a precmd() in zsh to check my stty settings
after every command, and alert me when they change, so I know what
command is causing the problem.
Only it looks like stty isn't actually the problem.
Here's the complete stty -a from a terminal where ^C no longer works:
speed 38400 baud; rows 32; 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
If I compare that to a stty -a from a freshly opened xterm, the only
differences are that the bad one has ignbrk ignpar -iexten -ixon, while
the normal one has -ignbrk -ignpar iexten ixon. intr = ^C in both cases.
So if I run stty -ignbrk -ignpar iexten ixon, the terminal should go
back to normal, right? Nope: if I type that, ^C still doesn't work.
And modes like raw, cooked and cbreak aren't there any more.
So there's something else causing the terminal to ignore ^C, having
nothing to do with stty, and I can't figure out what it is. Anyone
know where I should be looking?
(I'm going to set up that precmd to look at stty anyway -- because
stty IS getting changed, even if it seems to make no difference --
but it bugs me not to know what the real problem is.)
More information about the Techtalk