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>
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.
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];
}