summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbernard <[email protected]>2026-10-18 19:33:57 +0800
committerRbb666 <[email protected]>2026-10-29 14:48:33 +0800
commit24c624aa7aaa2bead494f1f56b3ac7f3af1c46cf (patch)
tree1431b5624e5ecff785c0d70cf84e4e6b9582dfbf
parent6040d6cf2cd96dbea5f57cf5537738a96f114ef0 (diff)
[components][lwp] handle TIOCLINUX and default window size
- return zero keyboard modifiers for TIOCLINUX instead of failing - keep terminal applications that probe console state working - initialize the TTY window size to 24x80 when none is reported
-rw-r--r--components/lwp/terminal/freebsd/tty_compat.c14
-rw-r--r--components/lwp/terminal/tty_device.c4
2 files changed, 16 insertions, 2 deletions
diff --git a/components/lwp/terminal/freebsd/tty_compat.c b/components/lwp/terminal/freebsd/tty_compat.c
index 08ff49f801..c89da7a315 100644
--- a/components/lwp/terminal/freebsd/tty_compat.c
+++ b/components/lwp/terminal/freebsd/tty_compat.c
@@ -547,9 +547,19 @@ int lwp_tty_ioctl_adapter(lwp_tty_t tp, int cmd, int oflags, void *args, rt_thre
error = (IOCTL(FIONREAD, args, fflags, td));
break;
-#ifdef USING_BSD_IOCTL_EXT
- /* TIOCLINUX */
+ case TIOCLINUX: {
+ /*
+ * Linux uses TIOCLINUX to obtain console keyboard modifier
+ * state. RT-Thread serial consoles do not expose that state,
+ * but applications such as mc only need this ioctl to be
+ * harmless when it is unavailable.
+ */
+ unsigned char modifiers = 0;
+ error = _copy_to_user(args, &modifiers, sizeof(modifiers));
+ break;
+ }
+#ifdef USING_BSD_IOCTL_EXT
case TIOCCONS:
args->cmd = TIOCCONS;
error = (sys_ioctl(td, (struct ioctl_args *)args));
diff --git a/components/lwp/terminal/tty_device.c b/components/lwp/terminal/tty_device.c
index 17364fabc1..b4b3637250 100644
--- a/components/lwp/terminal/tty_device.c
+++ b/components/lwp/terminal/tty_device.c
@@ -347,6 +347,10 @@ static void tty_init_termios(lwp_tty_t tp)
t->__c_ispeed = TTYDEF_SPEED;
t->__c_ospeed = TTYDEF_SPEED;
+ /* Keep terminal consumers usable when the host cannot report a size. */
+ tp->t_winsize.ws_row = 24;
+ tp->t_winsize.ws_col = 80;
+
memcpy(&t->c_cc, tty_ctrl_charset,
sizeof(tty_ctrl_charset) / sizeof(tty_ctrl_charset[0]));