fix(colors): only send terminal escape sequences to real terminals - #3622
Open
M7MMAD-OMAR wants to merge 1 commit into
Open
fix(colors): only send terminal escape sequences to real terminals#3622M7MMAD-OMAR wants to merge 1 commit into
M7MMAD-OMAR wants to merge 1 commit into
Conversation
apply_anyterm writes the generated OSC palette into every /dev/pts/*. Not every pty belongs to a terminal emulator: a process can hold one open without using it as a controlling terminal, and on a setup with KDE components installed kded6 does exactly that. What arrives there is not a recolour, it is a desktop notification whose body is the raw escape sequence -- which is what end-4#3453 is reporting. The same loop leaks processes. Each write is a disowned `cat` redirected into the pty, and on a pty nobody is reading it never finishes. On this machine 71 of them had accumulated, one batch per wallpaper change. Skip any pty that has no process using it as a controlling terminal. That is the property that separates a terminal emulator's pty from one that is merely held open, and it needs no allowlist of terminal names. Before/after on the same machine, per wallpaper change: leaked cat processes 3 -> 0 notification from kded6 yes -> no Fixes end-4#3453
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your changes
apply_anytermwrites the generated OSC palette into every/dev/pts/*.Not every pty belongs to a terminal emulator. A process can hold one open
without using it as a controlling terminal, and on a setup with KDE components
installed — which the Fedora dependency set pulls in —
kded6does exactlythat. What lands there is not a recolour; it is a desktop notification whose
body is the raw escape sequence. That is what #3453 is reporting, with the
screenshot of colour codes in a notification popup.
Here,
/dev/pts/2is held bykded6and has no controlling-terminal process,while every real terminal's pty has one:
The same loop also leaks processes. Each write is a disowned
catredirectedinto the pty, and on a pty nobody reads from, it never finishes. On this machine
71 of them had accumulated, one batch per wallpaper change.
The fix
Skip any pty that has no process using it as a controlling terminal. That is
exactly the property separating a terminal emulator's pty from one that is
merely held open, and it needs no allowlist of terminal names to maintain.
Measured on the same machine, per wallpaper change:
catprocesseskded6Fixes #3453
Is it ready? Questions/feedback needed?
Ready. Tested on Fedora 44 with Hyprland 0.56.2 and quickshell-git 0.2.1;
open terminals still recolour on a wallpaper change.
Two notes:
ps -tis in coreutils/procps and already assumed elsewhere in the repo, sothis adds no dependency.
fuser+ps commagainst alist of terminal names. The controlling-terminal check gets the same result
without anyone having to keep that list current.