tedbr...@gmail.com wrote:
> That suggests 2 possibilities. 1) wish is deliberately clearing
> the clipboard on exit (conditional on there having been a copy
> operation at some point in the run) or 2) the system itself is
> doing the clearing, say, during some resource cleanup, perhaps
> triggered by some channel still open when the process exits.
Under X11 there is no "clipboard" to clear. X11 has no centeral
storage called 'the clipboard'. Copy/paste between applications is
built by having the source and destination communicate directly over
the X11 server for data transfer from the source to the destination. A
'copy' operation, from the X11 viewpoint, is merely some program
announcing "I have data available for transfer". The transfer does not
actually occur until some other program sends that first one a message
that essentially says: "transfer the data you have to me now".
But there is no central clipboard "storage" area holding anything [1]. All
of it is implemented as direct message communication between the source
and destination programs. When the source exits, there is no longer
any program announcing "I have data available from a copy command" (at
least until some other program is asked to perform a "copy"), so there
is nothing for any other program to ask to receive.
The flow is this:
1) wish asserts "clipboard ownership" within the X11 server upon you
performing a "copy" command
2) the terminal program in which bash is running (xterm, rxvt,
gnometerminal, etc.), when you ask it to "paste" looks up in the X11
server to find out who "owns" the clipboard at the present time
3) the terminal program sends wish a message stating: "send me the data
you have selected for the clipboard"
4) wish receives the message, packages up the data, and sends the data
back
5) the terminal program receives the reply message, and inserts the
data into the pty that bash is listening on, and draws the relevant
font glyphs on the screen to show the pasted result
Once the process (wish) which had ownership exits, there is no longer a
'source' to contact to ask for the clipboard contents.
[1] This is how the X11 server handles things, and is the default way
that it is handled. But, if one runs a clipboard manager such as
xclipboard, then the flow is changed. The flow with a clipboard
manager is that the clipboard manager sees some program taking
ownership of the clipboard, and it immedately jumps in, asks for the
data contents via the same message protocol, holds onto a copy of the
data, and immedately, itself, asserts that it is now the "clipboard
owner". When this happens, the data has already been transferred out
of the wish process and another process (not 'wish') is asserting
'ownership', so any pastes occur by the destination asking that other
process for the data (i.e., the terminal asking xclipboard for a copy
of the contents it is holding).