https://bugs.gentoo.org/962830
https://sourceware.org/bugzilla/show_bug.cgi?id=33340#c23

From 02caf0c979fee9bfdac47dccbfb8147f8b8128eb Mon Sep 17 00:00:00 2001
From: "H. Peter Anvin" <hpa@zytor.com>
Date: Wed, 10 Sep 2025 17:59:54 -0700
Subject: [PATCH 2/3] termios: read output speed, not input speed

POSIX is pretty clear that if only one speed is supported, it is the
output speed setting that counts. On some platforms, the input speed
can even end up being reported as 0 for single speed configuration.

Thus, look at the output speed setting, not the input speed setting.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
---
 serialport.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/serialport.c b/serialport.c
index b3b9249a37c7..392ec61e95f2 100644
--- a/serialport.c
+++ b/serialport.c
@@ -1812,7 +1812,7 @@ static enum sp_return get_config(struct sp_port *port, struct port_data *data,
 #endif
 
 	for (i = 0; i < NUM_STD_BAUDRATES; i++) {
-		if (cfgetispeed(&data->term) == std_baudrates[i].index) {
+		if (cfgetospeed(&data->term) == std_baudrates[i].index) {
 			config->baudrate = std_baudrates[i].value;
 			break;
 		}
@@ -1820,7 +1820,7 @@ static enum sp_return get_config(struct sp_port *port, struct port_data *data,
 
 	if (i == NUM_STD_BAUDRATES) {
 #ifdef __APPLE__
-		config->baudrate = (int)data->term.c_ispeed;
+		config->baudrate = (int)data->term.c_ospeed;
 #elif defined(USE_TERMIOS_SPEED)
 		TRY(get_baudrate(port->fd, &config->baudrate));
 #else
-- 
2.51.0
