From 5238107f3e2020d87ce43000c1ea2fb5d35a8009 Mon Sep 17 00:00:00 2001 From: zhangkun Date: Wed, 10 Jun 2026 20:24:30 +0800 Subject: [PATCH] fix(session): avoid tty control in Treeland MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Skip opening the VT for Treeland single-mode user sessions, because the running Treeland compositor already owns the display server side. 2. Keep the VT-as-stdin and TIOCSCTTY path only for non-X11 sessions that start their own display server, such as standalone Wayland sessions. 3. Fix a fast-login race where dde-session became the controlling tty leader of /dev/tty2 while Treeland and dde-seatd were still completing VT transition. 4. The visible symptom was that dde-session appeared to crash shortly after login, while the real reason was a kernel SIGHUP caused by tty hangup. Log: Prevent Treeland single-mode dde-session from taking the VT as controlling tty. fix(session): 避免 Treeland 接管 tty 1. Treeland single-mode 用户会话不再打开 VT,因为显示服务端已经由正在运行的 Treeland compositor 持有。 2. 仅保留自带显示服务端的非 X11 会话继续走 VT stdin 和 TIOCSCTTY 路径,例如独立 Wayland 会话。 3. 修复快速登录时 dde-session 成为 /dev/tty2 控制终端 leader,而 Treeland 和 dde-seatd 仍在完成 VT 切换导致的时序问题。 4. 表现现象是登录后一两秒 dde-session 看起来像 crash,实际原因是 tty hangup 触发了内核发送的 SIGHUP。 Log: 避免 Treeland single-mode 下 dde-session 将 VT 作为控制终端。 PMS: TASK-390987 --- src/daemon/UserSession.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/daemon/UserSession.cpp b/src/daemon/UserSession.cpp index 8b27230..4a13109 100644 --- a/src/daemon/UserSession.cpp +++ b/src/daemon/UserSession.cpp @@ -132,12 +132,19 @@ namespace DDM { void UserSession::childModifier() { Auth *auth = qobject_cast(parent()); - // When the display server is part of the session, we leak the VT into - // the session as stdin so that it stays open without races + // When the display server is part of the session, leak the VT into + // the session as stdin so that it stays open without races. Treeland + // single-mode sessions run under an already active compositor, so they + // must not take the VT as their controlling terminal. if (auth->type != Display::X11) { - // open VT and get the fd - QString ttyString = TtyUtils::path(auth->tty); - int vtFd = ::open(qPrintable(ttyString), O_RDWR | O_NOCTTY); + QString ttyString; + int vtFd = -1; + + if (auth->type != Display::Treeland) { + // open VT and get the fd + ttyString = TtyUtils::path(auth->tty); + vtFd = ::open(qPrintable(ttyString), O_RDWR | O_NOCTTY); + } // when this is true we'll take control of the tty bool takeControl = false;