-
Notifications
You must be signed in to change notification settings - Fork 73
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
Not closing stdout when setting clipboard from stdin #20
Comments
See this StackOverflow question for an explanation of why xclip does not exit/close stdout until another selection is made: http://stackoverflow.com/questions/19254114/xclip-does-not-terminate-when-tracing-it Basically, it seems the only place the text buffer exists for other X clients to copy from is xclip itself, so if it exits the text goes with it. To stay alive, xclip fork's and daemonizes. I'm not sure how xsel handles this. I guess maybe xclip could close stdout when it knows it has nothing else to write to it? Original comment by: jaredcasper |
test_registers.vim can fail even if a clipboard manager is running. If a clipboard manager is not running, this test always fails with xclip. Use xsel as a workaround. astrand/xclip#20 suggests closing stdout when sending input via stdin. Environment - Ubuntu Xenial - Vim 7.4 (any app with broken clipboard code will do) - Neovim nightly Steps to reproduce: 0. Start the clipboard manager. 1. Open a file in Vim on Linux. Vim should have +clipboard enabled. 'set clipboard=' 2. Yank some text to the clipboard register. 3. Quit Vim. 4. Run 'cd /path/to/neovim/repo/' 5. Run 'make oldtest'. Do not run any individual tests. They likely pass with or without this fix. Before fix: test_registers.vim can fail. After fix: test_registers.vim always passes. Close neovim#7958 https://wiki.ubuntu.com/ClipboardPersistence#The_state_of_things
test_registers.vim can fail even if a clipboard manager is running. If a clipboard manager is not running, this test always fails with xclip. Use xsel as a workaround. astrand/xclip#20 suggests closing stdout when sending input via stdin. Environment - Ubuntu Xenial - Vim 7.4 (any app with broken clipboard code will do) - Neovim nightly Steps to reproduce: 0. Start the clipboard manager. 1. Open a file in Vim on Linux. Vim should have +clipboard enabled. 'set clipboard=' 2. Yank some text to the clipboard register. 3. Quit Vim. 4. Run 'cd /path/to/neovim/repo/' 5. Run 'make oldtest'. Do not run any individual tests. They likely pass with or without this fix. Before fix: test_registers.vim can fail. After fix: test_registers.vim always passes. Close neovim#7958 https://wiki.ubuntu.com/ClipboardPersistence#The_state_of_things
test_registers.vim can fail even if a clipboard manager is running. If a clipboard manager is not running, this test always fails with xclip. Use xsel as a workaround. astrand/xclip#20 suggests closing stdout when sending input via stdin. Environment - Ubuntu Xenial - Vim 7.4 (any app with broken clipboard code will do) - Neovim nightly Steps to reproduce: 0. Start the clipboard manager. 1. Open a file in Vim on Linux. Vim should have +clipboard enabled. 'set clipboard=' 2. Yank some text to the clipboard register. 3. Quit Vim. 4. Run 'cd /path/to/neovim/repo/' 5. Run 'make oldtest'. Do not run any individual tests. They likely pass with or without this fix. Before fix: test_registers.vim can fail. After fix: test_registers.vim always passes. Close #7958 https://wiki.ubuntu.com/ClipboardPersistence#The_state_of_things
I'm not a C developer but xsel's (github.com) function
The daemon can have a timeout set via the
So presumably the daemon remains as long as it's needed, just like xclip. Using xsel is suggested as a fix for this issue in the Tmux article on ArchWiki so perhaps the real difference between the two is just the closing of stdout as @astrand suggests above? |
This issue won't let parent shell process exit, i.e.: echo foo | xclip
exit # won't exit unless xclip process spawned above exits As a workaround one can wrap xclip() {
/usr/bin/xclip "$@" &> /dev/null
}
|
Cross-posting my solution from #34 (comment)_ , simply closing stdout/stderr using the shell works as well:
|
@leonardkoenig didn't know if such possibility. Another one I found is to use |
I'm having the darnedest time trying to reproduce this bug. I've tried setting my shell to zsh and compiling old versions of xclip. And yet, I'm always able to just type 'exit' to logout. @murlakatamenka, @leonardkoenig, could you please provide a little bit more information about how to trigger this bug? What exactly is hanging? Is it ssh? Or does your shell say something like "you have running jobs"? Which shell are you using? What version of xclip? |
I see that "nohup" is given as a solution. Should I presume it only works because it redirects stdout to a file? If not, then perhaps xclip could call |
xclip behaves weirdly in that it hangs around after invocation. There are lots of issues for this, and the common solution is to close stdout and stderr (astrand/xclip#20). Now we also close stderr and stdout, and it works again. Issue: #79
xclip does not appear to be closing stdout. This was noticed to cause compatibility problems when used with newer versions of tmux.
The tmux developer was able to identify this as the cause of an issue originally reported against tmux.
More info: https://sourceforge.net/p/tmux/tickets/40/?limit=10&page=1#9a2b
Reported by: wadetc
Original Ticket: xclip/bugs/9
The text was updated successfully, but these errors were encountered: