I have made the following observations:
$ xclip text.txt
The execution terminates instantly, it copies the content of text.txt
to the default selection XA_PRIMARY
which means you can paste it through your middle mouse button or xclip -o
.
When I want to see what xclip is doing, it does not terminate anymore:
$ xclip -verbose text.txt
Connected to X server.
Using UTF8_STRING.
Reading text.txt...
Waiting for selection requests, Control-C to quit
Waiting for selection request number 1
It does not terminate until I select something in my X11 system, for instance this very output I have pasted here. I would understand this, if the behavior is limited to verbose
. After all you want to sit around and see what happens.
I can reproduce the same behavior with strace
, but only if the fork option is provided
$ strace -f xclip text.txt
or when shelling out from Ruby with a system execution command that should return the output, which is in fact nothing.
$ ruby -e "`xclip text.txt`"
The hints that strace
gave, is that it is polling on a file descriptor to wait for an event. This event is satisfied if I select something. Is this behavior explainable? I have gotten evidence, that this is not reproducable on any system. Could this be related to the ticket #9 Not closing stdout when setting clipboard from stdin?
I am running xclip
version 0.12 on Ubuntu 13.04.
XClip forks a child when launched without
-verbose
. The only difference with-verbose
is that there is no child forked and the same original process handles ConvertSelection events.Usually in X Window toolkits copy/paste is implemented via X Selections:
Content of selection is stored in application itself and requested with ConvertSelection event ("convert" here because there is a way for client to ask for particular mimetype (or "view", or format) of selected data. Conversion, again, happens in the application which owns selected buffer.
Because of this architecture, there is no way to "copy text to system buffer and exit" - because you are a system buffer. XClip simulates "copy and exit" by forking and daemonizing.