]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
agetty: save the original speed on --keep-baud
authorKarel Zak <kzak@redhat.com>
Mon, 4 May 2020 10:27:42 +0000 (12:27 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 4 May 2020 10:27:42 +0000 (12:27 +0200)
agetty cycling through the baud rates specified on command line
(triggered by BREAK). Unfortunately, the original baud rate (probably
the best one) is tried only first time on --keep-baud.

Addresses: https://github.com/karelzak/util-linux/issues/1025
Signed-off-by: Karel Zak <kzak@redhat.com>
term-utils/agetty.8
term-utils/agetty.c

index 1c9e3884481f3676d90821c95dd44b96d5dd5fef..fa92df09cbb5c284b2b011041bb541ba2e9e1e0b 100644 (file)
@@ -238,8 +238,10 @@ Change root to the specified directory.
 Call vhangup() to do a virtual hangup of the specified terminal.
 .TP
 \-s, \-\-keep\-baud
-Try to keep the existing baud rate.  The baud rates from
-the command line are used when agetty receives a BREAK character.
+Try to keep the existing baud rate.  The baud rates from the command line are
+used when agetty receives a BREAK character.  If another baud rates specified
+then the original baud rate is also saved to the end of the wanted baud rates
+list.  It allows to return to the original baud rate after unexpected BREAKs.
 .TP
 \-t, \-\-timeout \fItimeout\fP
 Terminate if no user name could be read within \fItimeout\fP seconds.
index 861a56d1261e23ffcf69d74b572fe97757fa0414..46f1f243435a69a7c293875eb317231a1f0cc61a 100644 (file)
@@ -1279,9 +1279,17 @@ static void termio_init(struct options *op, struct termios *tp)
                ispeed = cfgetispeed(tp);
                ospeed = cfgetospeed(tp);
 
-               if (!ispeed) ispeed = TTYDEF_SPEED;
-               if (!ospeed) ospeed = TTYDEF_SPEED;
-
+               /* Save also the original speed to array of the speeds to make
+                * it possible to return the the original after unexpected BREAKs.
+                */
+               if (op->numspeed)
+                       op->speeds[op->numspeed++] = ispeed ? ispeed :
+                                                    ospeed ? ospeed :
+                                                    TTYDEF_SPEED;
+               if (!ispeed)
+                       ispeed = TTYDEF_SPEED;
+               if (!ospeed)
+                       ospeed = TTYDEF_SPEED;
        } else {
                ospeed = ispeed = op->speeds[FIRST_SPEED];
        }