Serial line terminal size.

Edward Tomasz Napierała trasz at FreeBSD.org
Wed May 24 08:55:22 UTC 2017


There's a problem with serial consoles - after logging in, the terminal
size is not set, ie it looks like this (notice the "0 rows; 0 columns;"):

speed 9600 baud; 0 rows; 0 columns;
lflags: icanon isig iexten echo echoe -echok echoke -echonl echoctl
        -echoprt -altwerase -noflsh -tostop -flusho -pendin -nokerninfo
        -extproc
iflags: -istrip icrnl -inlcr -igncr ixon -ixoff ixany imaxbel -ignbrk
        brkint -inpck -ignpar -parmrk
oflags: opost onlcr -ocrnl tab0 -onocr -onlret
cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts -dsrflow
        -dtrflow -mdmbuf
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
        eol2 = <undef>; erase = ^?; erase2 = ^H; intr = ^C; kill = ^U;
        lnext = ^V; min = 1; quit = ^\; reprint = ^R; start = ^Q;
        status = ^T; stop = ^S; susp = ^Z; time = 0; werase = ^W;

This makes some things - like vi(1) or tcsh(1) - handle the screen
in a rather strange, and quite broken, way.  I'd like to make this
work correctly by default by applying the patch below.  It should
be completely non-intrusive (the -z flag makes resizewin(1) not do
anything if the terminal size is not zero, and it's not zero for
network protocols and vt(4)), but since this involves running
things by default, including for root - I thought I'd better ask.
Thanks!

https://reviews.freebsd.org/D10642

Index: etc/root/dot.login
===================================================================
--- etc/root/dot.login
+++ etc/root/dot.login
@@ -5,5 +5,8 @@
 # see also csh(1), environ(7).
 #
 
+# Query terminal size; useful for serial lines.
+if ( -x /usr/bin/resizewin ) /usr/bin/resizewin -z
+
 # Uncomment to display a random cookie each login:
 # if ( -x /usr/bin/fortune ) /usr/bin/fortune -s
Index: etc/root/dot.profile
===================================================================
--- etc/root/dot.profile
+++ etc/root/dot.profile
@@ -8,3 +8,5 @@
 export TERM
 PAGER=more
 export PAGER
+
+if [ -x /usr/bin/resizewin ] ; then /usr/bin/resizewin -z ; fi
Index: share/skel/dot.login
===================================================================
--- share/skel/dot.login
+++ share/skel/dot.login
@@ -5,4 +5,5 @@
 # see also csh(1), environ(7).
 #
 
+if ( -x /usr/bin/resizewin ) /usr/bin/resizewin -z
 if ( -x /usr/bin/fortune ) /usr/bin/fortune freebsd-tips
Index: share/skel/dot.profile
===================================================================
--- share/skel/dot.profile
+++ share/skel/dot.profile
@@ -21,4 +21,7 @@
 # set ENV to a file invoked each time sh is started for interactive use.
 ENV=$HOME/.shrc; export ENV
 
+# Query terminal size; useful for serial lines.
+if [ -x /usr/bin/resizewin ] ; then /usr/bin/resizewin -z ; fi
+
 if [ -x /usr/bin/fortune ] ; then /usr/bin/fortune freebsd-tips ; fi


More information about the freebsd-hackers mailing list