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.
$ printf test | xclip
$ ps -C xclip
PID TTY TIME CMD
14115 pts/10 00:00:00 xclip
That xclip process is handling requests for the selection (here PRIMARY selection). But, if you select something in another application (or use xsel or xclip again to store something else), then that xclip process will concede the selection to that other application and terminate.
$ printf test | xsel
$ ps -C xclip
PID TTY TIME CMD
$ ps -C xsel
PID TTY TIME CMD
14212 ? 00:00:00 xsel
Above, xsel took over the selection from xclip.
You can find out who owns a given selection with:
#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
int main(int argc, char* argv[])
{
Display *d = XOpenDisplay(NULL);
Window w = XGetSelectionOwner(d, XInternAtom (d, argv[1], False));
printf("0x%08x\n", w);
return 0;
}
Then:
$ make xgo LDFLAGS=-lX11
$ ./xgo PRIMARY
0x07000001
That will give you the window ID. You can use xprop -id or xwininfo -id on that id, but in the case of xclip/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.
ps -efl --forestwill showxclipdisowned from its parent and re-attached higher up in the process tree similar to a daemon. Note to future readers who want to run this c code on ubuntu 16.04, I needed tosudo apt-get install libx11-dev, and compile withgcc -o clip clip.c -lX11to avoid make errors. – the_velour_fog Jun 03 '17 at 00:11