Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xsel silently fails to set selection to file contents if over ~4000 bytes #33

Open
skierpage opened this issue Sep 10, 2019 · 2 comments

Comments

@skierpage
Copy link

xsel version 1.2.0 (Fedora package xsel-1.2.0-24.fc30.src.rpm)
Fedora 30 KDE Spin
X.Org X Server 1.20.5. (xorg-x11-server 1.20.5-4.fc30).

After writing all the below this sounds like closed bugs #13 and #14, but I think I'm running latest version 1.20 ??!

I've used xsel -b for years, thanks! Today I tried to set the clipboard selection to the contents of a 9 kB file with xsel -b < MYFILE and after 10 minutes of WTF I realized the command was failing and setting the clipboard contents to empty, even though its exit status $? is 0. When it fails it appends xsel: BadWindow (invalid Window parameter): Resource temporarily unavailable to ~/.xsel.log.

I reduced and increased the file size until I determined that xsel -b < SOMEFILE succeeds with a 4075-byte file and fails with 4076 bytes... but now 4075 is failing too! So the limit varies. I can use Ctrl-C in GUI apps to set the clipboard selection to much bigger files.

I ran strace on the failure vs/ successful xsel of another file, and the contents are essentially the same, then I realized there's a child process ;-) ; with -ff the child process gets some errors from recvmsg(3, {msg_namelen=0}, 0) = -1 EAGAIN (Resource temporarily unavailable) but seems to keep going and writes bits of the file until it opens /usr/share/X11/XErrorDB and reports errors. I can upload the strace if it will help.

I'll file a separate bug that when the child process fails with exit_group(1), the error isn't reported to the parent.

@skierpage
Copy link
Author

I built latest xsel from source and still have this problem. Sometimes the child process that xsel forks times out with BadWindow and sometimes doesn't. When I first ran xsel -b --nodetach < MY_4k_FILE, it took many seconds before printing out

/tmp/xsel_build/bin/xsel: BadWindow (invalid Window parameter): Resource temporarily unavailable

and exit, but if I repeat the command it fails quickly with the same error... and then other times it works, waiting for someone to request the selection and providing it correctly.

@amerlyq
Copy link

amerlyq commented Nov 29, 2020

Maybe this commit from fork will fix it?
On input, dont exit parent (returning to invoker) until either select… · mckellyln/xsel@b7d8442⠀
https://github.com/mckellyln/xsel/commit/b7d8442d9f661550ef78a4f1bd164bf7304f70db

However, neovim simply started preferring xclip due to xsel codebase being neglected...
nvim xsel not working properly? · Issue #5853 · neovim/neovim
neovim/neovim#5853

StanAngeloff added a commit to StanAngeloff/longitude that referenced this issue Nov 23, 2022
xsel was choking on large copies.
See kfish/xsel#33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants