After reading this question about the X clipboard getting cleared when vim is exited I learned that the X window clipboard only exists while the program – from which the selection was obtained – remains open.
It is because of this behaviour that programs like "glipper" and "parcellite" exist.
If the X clipboard is cleared every time a program is exited, how do programs like xclip
and xsel
work?
And what are the security implications of using programs like this? For example, if a password was copied to the clipboard, could this password be saved into some temp file that could be accessed by programs or users?
Best Answer
Unless there's a clipboard application like
xclipboard
,clipit
... that steals the selections from them,xsel
/xclip
will fork a background process to handle the future selection requests as long as they own the selection.That
xclip
process is handling requests for the selection (here PRIMARY selection). But, if you select something in another application (or usexsel
orxclip
again to store something else), then thatxclip
process will concede the selection to that other application and terminate.Above,
xsel
took over the selection fromxclip
.You can find out who owns a given selection with:
Then:
That will give you the window ID. You can use
xprop -id
orxwininfo -id
on that id, but in the case ofxclip
/xsel
, you won't get much information.On GNU/Linux based systems,
ltrace
is useful to see what's happening at the X library API level.See also Capture the X11 protocol's traffic to see what's happening at the X11 protocol level.