I'm encountering an issue where running xclip through shell-command in Emacs to copy text to the clipboard hangs. Here's the minimal code snippet that reproduces the problem:
(shell-command "echo foobar | xclip -selection clipboard")
When I execute this, Emacs freezes. Running the same xclip command directly in a terminal works without any issues.
I've tried various workarounds, such as using the -i option with xclip, redirecting stderr to /dev/null and executing xclip in the background with nohup and &, but none have resolved the issue.
I'm running Emacs on Manjaro with Emacs 29.1. Any insights or solutions to prevent Emacs from hanging when using xclip in this way would be greatly appreciated.
I was curious and played a bit with this problem. Using
nohupin conjunction withshell-commandseems to do what you want:nohupwould normaly create a filenohup.out, the redirections are there to prevent that.