We recently reinstalled our server due to a disk failure, and now we're having an issue with resizing terminals. We installed Debian 6.0.6.
Symptoms
When you resize a terminal, no ncurses-based apps (tested: ytalk, irssi, screen, tmux, some of the ncurses example applications) seem to resize correctly. The screen typically ends up blank. Forcing a redraw in the application will redraw using the old terminal size.
When resizing a window at a bash (4.1.5(1)) prompt, the COLUMNS and LINES variables are never updated.
Diagnostics
Attempting to trap the SIGWINCH in bash, it seems it is never being received. This was tested with:
trap 'touch /home/user/sigwinch' SIGWINCH
trap 'touch /home/user/sigusr1' SIGUSR1
kill -s SIGWINCH $$
kill -s SIGUSR1 $$
Which should have created both files in my home directory. It only created /home/user/sigusr1
.
Trying to kill -s SIGWINCH $$
does not cause an update of the $COLUMNS/$LINES variables.
Enabling checkwinsize
(shopt -s checkwinsize
) will cause bash to update $COLUMNS/$LINES upon return from any application (as expected). This leads to the following after resizing a terminal with checkwinsize
enabled:
$ echo $COLUMNS ; ls > /dev/null ; echo $COLUMNS
72
107
Changing my login shell to something like tcsh and attempting to resize the terminal works as expected, as does bash on other boxes I tested.
I tried removing my .bashrc and it did nothing. This problem is occurring for several other users with varying bash configurations in both PuTTY and some sort of rxvt-type terminal from a Linux box.
strace
I ran strace on bash and tried resizing the terminal, nothing came through (it remained blocked on a read
call immediately after printing the prompt).
I hit return on an empty line, and bash did a whole bunch of stuff. The output I believe to be relevant is: (full strace)
1: rt_sigprocmask(SIG_SETMASK, [WINCH], NULL, 8) = 0
2: rt_sigaction(SIGWINCH, {0x80e2c20, [], SA_RESTART}, {0x809c310, [], 0}, 8) = 0
3: rt_sigprocmask(SIG_BLOCK, [INT], [WINCH], 8) = 0
4: write(2, "aa:~$ ", 6) = 6
5: rt_sigprocmask(SIG_SETMASK, [WINCH], NULL, 8) = 0
6: rt_sigprocmask(SIG_BLOCK, NULL, [WINCH], 8) = 0
7: read(0,
Which shows bash, to my understanding: (I could be horribly misunderstanding this. I'm way out of my element here.)
1: Disabling delivery of the SIGWINCH signal, when previously it was allowed.
2: Registering a handler for the SIGWINCH signal.
3: Masking some other combination of signals. As evidenced by line 5, this does not include SIGWINCH.
4: Printing the prompt.
5: Masking SIGWINCH, where previously nothing was blocked.
6: Masking the "union of null and SIGWINCH" which, to my understanding, would result in SIGWINCH being masked.
7: Waiting on input.
This same strace performed on a box without these issues (Ubuntu, bash 4.2.24(1)) resulted in:
1: rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
2: rt_sigaction(SIGWINCH, {0x49e320, [], SA_RESTORER|SA_RESTART, 0x7f7ef49f64c0}, {0x457880, [], SA_RESTORER, 0x7f7ef49f64c0}, 8) = 0
3: rt_sigprocmask(SIG_BLOCK, [INT], [], 8) = 0
4: write(2, "aaaaaaa:~$ ", 11) = 11
5: rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
6: rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
7: read(0,
Question
What in the hell is going on and why is my bash broken? :(
I'm guessing there's probably just an option somewhere that defaulted to something unexpected, but hours on Google have turned up nothing.
Any help and/or pointers are greatly appreciated. This is really frustrating.
Thank you.
exec bash
by hand (so it's no longer a login shell) does it still misbehave? If not, what aboutexec bash -l
(so it's a login shell)? If so, then something's up with your login scripts (/etc/profile
/etc/profile.d/
~/.bash_profile
~/.profile
), but I don't even know what to tell you to be looking for that can tell the shell not toSIGWINCH
.exec bash
andexec bash -l
exhibit the same behaviour. I suppose it's a small consolation that I'm not alone in this. I'm thoroughly confused as to what would cause this, though. The colo installed a minimal install from a freshly downloaded Debian image. I'll have to try installing locally and see if there's any issues and (assuming none, since this appears to not happen for other people), start comparing to the running system./etc/bash.bashrc
and all of the/etc/profile
and/etc/profile.d
files are unchanged from a clean install. I've downloaded the bash source (apt-get source bash
) and am playing with various arguments to./configure
to try and narrow the problem down before I dig into the source.--disable-readline --enable-minimal-config --disable-job-control
, ran an strace to see which files itopen
'd, renamed all those files, then logged in again. Same issue. I've fairly definitely ruled out any configuration changes with bash itself.