Bug 173999 - konsole doesn't report size to TIOCGWINSZ ioctl for ncurses applications
Summary: konsole doesn't report size to TIOCGWINSZ ioctl for ncurses applications
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Unclassified
Component: general (show other bugs)
Version: 2.2
Platform: unspecified Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-31 21:53 UTC by Christopher Neufeld
Modified: 2011-08-05 14:47 UTC (History)
9 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.8


Attachments
Screenshot of Konsole (116.76 KB, image/png)
2009-01-28 00:17 UTC, Thomas Zell
Details
Using the curses-based sysinstall utility (75.69 KB, image/png)
2010-08-03 15:12 UTC, funmol
Details
When Konsole shows terminal output correctly after using sysinstall (123.80 KB, image/png)
2010-08-03 15:14 UTC, funmol
Details
When Konsole doesn't show terminal output correctly afer quitting sysinstall (132.72 KB, image/png)
2010-08-03 15:17 UTC, funmol
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christopher Neufeld 2008-10-31 21:53:53 UTC
Version:           2.2 (using 4.1.71 (KDE 4.1.71 (KDE 4.2 >= 20081023)), compiled sources)
Compiler:          gcc
OS:                Linux (x86_64) release 2.6.25

I use a lot of konsoles, sometimes running "less", sometimes "jove" or some similar full-screen software.  After installing kde4 compiled from svn, those programs that depend on knowing the size of the terminal in which they're running don't display correctly.  I tracked this down to the ioctl(TIOCGWINSZ).  When things are working correctly, it will return ws_row and ws_col set to the size of the konsole.  When not working correctly, those two parameters are returned as zero, and ncurses applications either use only a part of the screen or get badly jumbled.
Comment 1 Christopher Neufeld 2008-11-18 05:28:10 UTC
Well, I no longer see the misbehaviour.  It appears it was fixed in a later revision.  Anyway, I'm closing this as WORKSFORME.  If it comes back, I'll reopen and try to provide more details.
Comment 2 Thomas Zell 2009-01-28 00:15:23 UTC
It's still broken for me ...
Comment 3 Thomas Zell 2009-01-28 00:17:24 UTC
Created attachment 30662 [details]
Screenshot of Konsole
Comment 4 Thomas Zell 2009-01-30 23:21:06 UTC
This bug only seems to occur if I select the "Misc Console" font. I have not been able to reproduce it with other fonts.

Can someone please reopen this bug?
Comment 5 Thomas Zell 2009-01-30 23:26:46 UTC
My above observation was incorrect. It does not depend on the font, but on the size of the window. The above bug is triggered only if the size is exactly 80x40 characters.
Comment 6 Christopher Neufeld 2009-02-07 22:01:57 UTC
Well, I'm seeing the problem again.  I've been trying to work around it by putting

eval `resize`

into strategic bash initialization scripts, but it does seem to me that things got better and then broke once again.  I'm using revision 919729.
Comment 7 Graeme Hewson 2010-07-10 20:22:10 UTC
I see this bug using Kubuntu 10.04 (Lucid Lynx) and Konsole 2.4.2.

I used the Special Applications Settings dialogue to set the default Konsole size to 80 columns by 40 rows. With the default Nouveau graphics driver for nVidia supplied with Kubuntu, on my 1680x1050 pixel monitor, I specified 590,688.

When subsequently starting Konsole, the bug was intermittent. It seemed the first time I started Konsole, and sometimes after that, "stty -a" showed the required "rows 40; columns 80;". Otherwise, it was "rows 0; columns 0;".

Setting a lower default height (such as 35 rows), the bug (if it's the same bug) changed, but was still intermittent. Mostly "stty -a" showed the required size, but sometimes it showed "rows 40; columns 80;". Wrong height!

I've now installed the "NVIDIA accelerated graphics driver (version current)", and the bug is still present, but perhaps a little more consistent. Using the previous Special Applications Settings value of 590,688, "stty -a" shows "rows 43; columns 80;", and so it does every time I start Konsole. Setting rows under 40, again, stty shows the correct values. With 40 rows (setting 590,644 now with the new driver), stty shows "rows 40; columns 80" the first time I start Konsole, and "rows 0; columns 0;" after that.

As for the resize command, I've found it's not necessary to eval it. Starting with stty showing "rows 0; columns 0;", just "resize" or "resize > /dev/null" gives the required result.
Comment 8 Jonathan Wakely 2010-07-22 13:44:44 UTC
related to Bug 203185 and Bug 176902 ?
Comment 9 funmol 2010-08-03 15:12:34 UTC
Created attachment 49776 [details]
Using the curses-based sysinstall utility
Comment 10 funmol 2010-08-03 15:14:05 UTC
Created attachment 49777 [details]
When Konsole shows terminal output correctly after using sysinstall
Comment 11 funmol 2010-08-03 15:17:07 UTC
Created attachment 49778 [details]
When Konsole doesn't show terminal output correctly afer quitting sysinstall

It uses only a port of the window length for showing terminal output, instead of using the whole window length.
Comment 12 funmol 2010-08-03 15:17:41 UTC
I'm in a similar situation as Graeme Hewson, but on PC-BSD 8.1 (FreeBSD), using KDE 4.4.5.

My system has the NVIDIA driver 256.44 installed and my Konsole size is 80x40 too.

Sometimes, after using the ncurses-based FreeBSD "sysinstall" program, when I quit the utility, Konsole doesn't show terminal output in the whole length of the window, but uses only a part of it.

This problem doesn't appear each time, but almost 95% of the time, whatever Konsole is launched for the first time afer KDE login or not, or was just opened or not (clear window or showing past output) before starting "sysinstall".

A little work-around is to clear history and reinitialize Konsole pressing Ctrl+Alt+X.
Comment 13 Pierre 2010-09-14 22:53:16 UTC
I have the same bug, using kubuntu Ubuntu 10.04.1 LTS with KDE 4.5.1 and konsole 2.5.
My test application is aptitude.

For me, opening a new tab in konsole fixes the issue, for both the old and the new tab.
The resize command works as well.
Comment 14 Pierre 2010-09-20 16:17:02 UTC
It seems to me that the bug occurs only when the scroll bar is hidden in the konsole profile.

Hopefully this will help solving the problem.

Also, the bug appeared for me when I decided to make some cleaning in my ~/.kde personal directory.
I am still in the process of investigating what are the differences between my old .kde (which I have saved, and where there is no bug if I restore it) and the new one.
Comment 15 Chris Samuel 2010-10-11 12:26:07 UTC
Just to confirm that I'm seeing what I believe to be this issue with KDE 4.5.x (currently KDE 4.5.2, Konsole 2.5.2) in Kubuntu 10.10.  Every time I log in the two Konsole's that start up for me seem to default to a smaller height than they are actually running at - this behaviour is seen in vi, top, less, etc.

If I resize the window it picks up the correct height *for that tab* (have to repeat for all 10), until the next time I logout and login again.

Font is DejaVu Sans Mono (9pt), Intel chipset, Xorg 7.5 with Intel driver 2.12.0-1ubuntu5:

(II) intel(0): Integrated Graphics Chipset: Intel(R) G33
Comment 16 Jonathan Wakely 2010-10-11 12:55:17 UTC
I think that's Bug 176902
Comment 17 Chris Samuel 2010-10-11 14:10:37 UTC
Good catch Jonathan, thanks!
Comment 18 Thomas Zell 2010-10-11 14:39:41 UTC
*** This bug has been confirmed by popular vote. ***
Comment 19 Thomas Zell 2010-10-11 14:43:13 UTC
Bug 176902 seems to be a duplicate of this bug report.
Comment 20 Jonathan Wakely 2010-10-11 14:59:15 UTC
(In reply to comment #19)
> Bug 176902 seems to be a duplicate of this bug report.

possibly - but this report seems to be about an ioctl originally, and was closed as WORKSFORME, then reopened with possibly different symptoms

Bug 176902 has less confusing info, has steps to reproduce, and has analysis of the bug (see Bug 176902 comment 10 and Bug 176902 comment 11) as well as a possible fix (Bug 176902 comment 12) - so keeping that one open makes more sense to me

though TBH I don't care which one is closed as a dup, it'd just be nice if someone would bloody fix it after all this time.  for a while I was running a hacked version of konsole which fixed it by brute force, but that got lost by an upgrade and the hack was not a proper fix and not suitable for checking in
Comment 21 Martin von Gagern 2011-04-06 10:06:16 UTC
(In reply to comment #20)
> a possible fix (Bug 176902 comment 12)

Implemented this, attached in bug 176902 comment 19. Give it a try, if it works here as well, dup this one here to that one, as that one has the patch.
Comment 22 Jekyll Wu 2011-08-04 16:57:54 UTC
See comment #10, #11, #19 and #21 in bug #176902

*** This bug has been marked as a duplicate of bug 176902 ***
Comment 23 Kurt Hindenburg 2011-08-05 14:47:41 UTC
Git commit 7e00edd5166096feb59ffa694b6a6ff858fe1924 by Kurt Hindenburg.
Committed on 05/08/2011 at 16:40.
Pushed by hindenburg into branch 'master'.

Make sure pty device has right size before terminal process queries it.

Whenever TeminalDisplay is resized, konsole tells the underlying
pty device its new size by calling Pty::setWindowSize(). However,
current code can't guarantee when the terminal process starts and
queries the pty device about its size, the pty device already has the
right info. This has caused some long known bugs, such as #176902.

This patch tries to guarantee that important assumption. It currently
uses a hard-coded small delay, which works pretty well in practice
although not that elegant.

Patch by Jekyll Wu <adaptee@gmail.com>

I think this is better than leaving the situation as it is.  This may
be backported if no issues are found.
BUG: 173999
BUG: 176902
BUG: 203185
BUG: 229058
REVIEW: 102061
FIXED-IN: 4.8

M  +7    -0    src/Emulation.h
M  +0    -1    src/Application.cpp
M  +1    -0    src/Session.cpp
M  +30   -6    src/Emulation.cpp

http://commits.kde.org/konsole/7e00edd5166096feb59ffa694b6a6ff858fe1924