Best way of finding terminal width/height?

Grant Edwards grante at visi.com
Thu Feb 9 10:27:02 EST 2006


On 2006-02-09, Joel Hedlund <joel.hedlund at gmail.com> wrote:
>> It didn't insert an EOF, it just caused read() to return
>> "prematurely".  You should call read() again until it receives
>> a _real_ EOF and returns ''.
>
> Copy that. Point taken.
>
>> There appear to be a couple problems with this description:
>>
>>  1) It says that read() in blocking mode without a size
>>     parameter it will read until EOF.  This is not what happens
>>     when reading a terminal that receives SIGWINCH, so you're
>>     right: read() it isn't working as described.
>>
>>  2) It also says that it makes sense to continue to read a tty
>>     after you get an EOF.  That's not true.  Once you get an
>>     EOF on a tty, there's no point in reading it any more:
>>     you'll continue to get an EOF forever.

I should qualify comment 2) with the disclaimer that that's how
tty devices on Unix/Linux work -- I don't know about windows.

> Should I post a bug about this?

Sure.  I was going to do that yesterday, but I realized that I
didn't know how/where to do it.  I assume there's a link
somewhere at www.python.org, but I haven't had a chance to look
yet.

-- 
Grant Edwards                   grante             Yow!  I wish I was on a
                                  at               Cincinnati street corner
                               visi.com            holding a clean dog!



More information about the Python-list mailing list