URL: <https://savannah.gnu.org/bugs/?68138>
Summary: detaching may fail with empty terminfo and leave the
session attached
Group: GNU Screen
Submitter: None
Submitted: Di 10 Mär 2026 23:07:44 UTC
Category: Program Logic
Severity: 3 - Normal
Priority: 5 - Normal
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Unlocked
Release: 5.0.1
Fixed Release: 5.0.2
Planned Release: 5.0.2
Work Required: None
_______________________________________________________
Follow-up Comments:
-------------------------------------------------------
Date: Di 10 Mär 2026 23:07:44 UTC By: Anonymous
== Summary ==
Running `screen -d <session>` against an already attached session can fail
with:
Cannot find terminfo entry for ''.
When this happens, the session stays attached instead of being detached.
== Reproducer ==
1. Start a session:
screen -S ctop
2. In terminal 1, leave the session attached.
3. In terminal 2, try to detach it:
screen -d ctop
4. Result:
Cannot find terminfo entry for ''.
The session remains attached.
== Root cause ==
The problem is in the server-side detach path.
For unauthenticated detach requests, the code went through `FinishAttach()`
instead of `FinishDetach()`.
That is wrong because detach messages do not carry attach-specific terminal
data.
As a result, the detach flow could still create a temporary display with an
empty terminal name and then run attach-style terminal initialization, which
led to:
Cannot find terminfo entry for ''.
So the bug is not really a missing client-side TERM fallback.
The real issue is that the detach path incorrectly entered attach
initialization.
== Fix ==
The attached fix does the following:
* route non-auth `MSG_DETACH` / `MSG_POW_DETACH` directly to `FinishDetach()`
* keep `CreateTempDisplay()` only for authenticated detach, where a password
prompt may be needed
* add validation for the no-auth detach request before calling
`FinishDetach()`
This avoids attach initialization entirely in the normal detach case.
== Regression test ==
A regression test was added for this scenario.
The test:
* starts a detached session
* attaches a real client
* runs `screen -d <session>`
* verifies that no empty-terminfo error appears
* verifies that the session becomes detached
* was checked against both:
* the fixed tree: test passes
* a pre-fix tree: test fails
== Notes ==
This fix only affects sessions started with the fixed screen binary.
Already-running sessions created by an older screen server process still keep
the old buggy behavior until restarted.
== Result after fix ==
After the fix, detaching a newly created session works as expected:
screen -d <session>
[pid.session detached.]
and `screen -ls` shows the session as detached.
_______________________________________________________
File Attachments:
applies to 464c8d8f945f53f8cbb854517279349e09d74756 (Release v.5.0.1)
Name: screen-fix-vs-screen-v5.diff Size: 7,1KiB
<https://file.savannah.gnu.org/file/screen-fix-vs-screen-v5.diff?file_id=58327>
AGPL NOTICE
These attachments are served by Savane. You can download the corresponding
source code of Savane at
https://savannah.gnu.org/source/savane-5479f0ac3e1f014845fd281c379bc3ccb7a72723.tar.gz
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?68138>
_______________________________________________
Nachricht gesendet über Savannah
https://savannah.gnu.org/
signature.asc
Description: PGP signature
