Debian SSH - Resizing terminal does not register with bash
Something had been bugging me about the strace output. Namely that it seemed that when bash started, it seemed it already had SIGWINCH masked. Couldn't be sure, didn't understand half of what it was spitting out, but it was certainly worth some exploration at this point.
I ran strace -o strace_file bash -l
from a tcsh shell, where the issue was not present. bash never masked SIGWINCH. When it was masking it, it was only because it was attempting to restore the previous mask. So where was the initial mask coming from?
Some more time on Google and a fresh mind and I found this post which mentioned that aptitude can sometimes cause sshd to be started with SIGWINCH masked, and that it will then be inherited by all the spawned processes straight down to the shell.
I tried ps axwwws
(all, detached, wide output, signals). It showed several of the spawned sshd processes had SIGWINCH masked.
The server/listening process (sshd itself) did not. Nor did the processes which were hosting connections which used tcsh. That part is confusing to me. I'm guessing (again, knowing very little about any of this) that the signal mask is process-group wide or something, tcsh was resetting it on start, and that was affecting ssh as well.
So, on a whim, I connected in with tcsh (to get a clean term with no SIGWINCH mask), restarted ssh, changed my shell back to bash... And it worked! Everything's back to normal!
As far as I know aptitude has not been run on this box, and ssh has been restarted a few times for configuration changes. Somewhere along the line the mask made its way in, though, and infected everything like a bad disease.
To recognize the same issue, run ps axwwws | grep sshd
and look for sshd processes with the second long column (BLOCKED
) has 0x8000000 set. That's SIGWINCH. Something like:
0 26425 0000000000000000 0000000008000000 0000000000001000 0000000180004003 Ss ? 0:00 sshd: aa [priv]
1000 26430 0000000000000000 0000000008000000 0000000000001000 0000000180010000 S ? 0:02 sshd: aa@pts/24
To fix it (possibly not the best solution, worked for me):
$ sudo apt-get install tcsh
[snip]
$ chsh -s /bin/tcsh
[connect in with a new connection, leave the old one open in case of any issues with tcsh]
$ sudo /etc/init.d/ssh restart
And it's fixed.
Cheers!