COLUMNS and LINES environment variables

Damien Miller djm at
Tue Sep 1 10:00:30 AEST 2015

On Tue, 1 Sep 2015, Martti K?hne wrote:

> Hello openssh developers,
> Instead of just playing nethack, I've been building a client that
> would log in to nethack at and using a pipe to get the login data
> from pwsafe directly onto the server.
> All of this works brilliantly after playing with some stty magic (full
> script in [0]), however, this way the terminal size is burned into
> 80x24, which is way smaller than my graphical terminal.
> Anyway, I proceeded grepping some of the openssh source code and wrote
> this patch [1], which I have locally tested with great success.

The problem with doing it via enviornment variables is that they
will become invalid if the client ever changes the size of their
window. TTYs support sending SIGWINCH for this and OpenSSH handles
this already.

Your program should be able to get the correct window size at any
time using:

struct winsize ws;
if (ioctl(ttyfd, TIOCGWINSZ, &ws) != 0)


More information about the openssh-unix-dev mailing list