astrand/xclip

xclip causes terminal to hang when exiting after piping input

0d-gg opened this issue · 0 comments

I have noticed that in some scenarios, xclip will cause my terminal to hang after piping output to it. I expect it to write the contents to the clipboard and exit immediately, but the process seems to stay open and "hold" the clipboard until something else writes to it. Sorry if I am using the wrong terminology here, I am not familliar with the internal workings of this.

Steps to reproduce

  1. Open a new terminal
  2. cat /etc/passwd | xclip -selection clipboard
  3. type "exit"
  4. Terminal window does not exit.
  5. Pasting the contents has no effect, but if I copy something else to my clipboard from another source, it will exit immediately (the process terminates)

Workaround

I use a "clip" alias for this, and changed it from the above to alias clip='xclip -selection clipboard >/dev/null 2>&1'.

Environment

OS: Ubuntu 24.04 LTS
Kernel: 6.8.0-40-generic
Desktop Environment: GNOME
Session Type: X11
Window Manager: Mutter
Terminal: kitty 0.32.2
Shell: zsh 5.9