fix: detach wl-copy from parent process on Wayland clipboard copy#344
Open
ScriptingDad wants to merge 1 commit intosavedra1:mainfrom
Open
fix: detach wl-copy from parent process on Wayland clipboard copy#344ScriptingDad wants to merge 1 commit intosavedra1:mainfrom
ScriptingDad wants to merge 1 commit intosavedra1:mainfrom
Conversation
wl-copy must stay alive to hold the Wayland clipboard seat. Using cmd.Run() caused it to be killed when the clipse TUI exited, clearing the clipboard. Switching to cmd.Start() with Setsid:true detaches wl-copy into its own session so it survives the parent process exit.
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.
I was having problems using clipse where copying from the TUI would appear to work but nothing could be pasted. After debugging, the issue is that when the clipse terminal window closes after selection, it kills the wl-copy child process along with it — and on Wayland, wl-copy must
stay alive to hold the clipboard seat. When it dies, the clipboard is immediately empty.
The fix is a 3-line change: use cmd.Start() with Setsid: true instead of cmd.Run(). This puts wl-copy in its own process session so it survives the parent exiting. When a new item is copied, the old wl-copy exits naturally as it loses clipboard ownership to the new one — no process
leak.
Environment: Ubuntu 22.04, Sway. My work machine on Ubuntu 24.04 doesn't exhibit this — likely because it has a clipboard persistence daemon running that masks the bug.
I used Kiro to help locate and implement the fix.