Page MenuHomeVyOS Platform

Improve serial console (add options to auto-detect or hard-set terminal size)
Open, WishlistPublic


Add nodes under system console device ttySx named size auto and size fixed <rows>x<columns>.
auto would perform size detection by adding functions in .profile executed if $(tty) == ttyS*, via either one of the methods described here:
or by using xterm's resize utility (on Debian it's avaliable packaged in xterm, unfortunately it isn't available by itself like on other distros, f.e. Fedora has xterm-resize, but the source is available and under a free license if we don't want to install the whole xterm package, we can build just resize on our own).

As the xterm's resize utility is much faster than the pure bash solutions, that would be preferred, so it can be called after every command exit as a trap on DEBUG. Otherwise the size would be detected only on login and a resize would require the user to run resize by himself, or have a penalty of approx. 0.5s after each command exit. There's no way to detect a serial terminal window resize automatically, a trap on every command exit is the best solution.

The other node size <rows>x<columns> would set a fixed console size via stty.


Difficulty level
Unknown (require assessment)
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Behavior change

Event Timeline

jjakob triaged this task as Wishlist priority.May 12 2020, 12:42 PM
jjakob created this task.
jjakob created this object in space S1 VyOS Public.
pasik added a subscriber: pasik.May 12 2020, 6:33 PM

Should we trap the signal in vash, set an env value and use it with vyos?

There is no way to send a SIGWINCH over serial - see
We can, however, poll the terminal for its size - at login and on every command exit (bash trap DEBUG)

Note however, that of the 2 mentioned shell script methods to poll the terminal emulator for its size, the first one (res()) didn't work for me (using GNU screen as the terminal, it returned an error after timeout), the 2nd one (res2()) worked (which is the one using xterm's special escape code). Both suffer from the same 0.5s delay, so the best would be to use xterm-resize, which is almost immediate. Not complicated to port in the vyos library, replacing the current code and therefore only run when required

I think this would be even better: (it's a stripped down resize.c), I haven't tested it yet though. I'm not sure where it would be best to put it, as it's a separate compiled program. Other such programs have their own repositories (vyos-utils), maybe 'vyos-xterm-resize' would be best.
I'm busy with work projects until at least next week so VyOS is on the backburner, when I get more time I'd like to rewrite the old console setup code.