This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Writing to /dev/clipboard from multiple processes in Bash gives inconsistent behaviour


On Fri, Feb 13, 2015 at 01:09:32PM +0300, Andrey Repin wrote:
> Greetings, Corinna Vinschen!
> 
> >> And my mail client actively flashing "paste" buttons, when the script is
> >> working in background. May be that's it.
> >> 
> >> This is more visible:
> >> $ while true; do { i=$(( $i+1 )); echo > /dev/clipboard; for n in {1..10}; do echo $n; done > /dev/clipboard; grep -q 10 /dev/clipboard || { grep 10 /dev/clipboard && echo $i;};}; done;
> 
> > Nope, no way.  I'm running this latter test for 45 minutes now, with
> > no output.
> 
> Then I presume this is environmental issue.
> I can think of at least 3 programs that hook clipboard events on my side, and
> I can't easily get rid of any of them. Because of "resident" nature of each.

Yes.  I suspect this may be somewhat of a smoking gun:

> >> And my mail client actively flashing "paste" buttons, when the script is
> >> working in background. May be that's it.

I'm running a bunch of Microsoft Office applications which I know do
"helpful" things to the Windows clipboard.  It hadn't occured to me that
they may be causing BLODA-like problems in the way they interact with
it.

On that basis, my current hypothesis is that the problematic commands are
making multiple writes to /dev/clipboard very rapidly, which triggers a race
condition with the non-Cygwin clipboard-manipulating tools.  Adding a cat into
the pipeline adds cat's buffering behaviour, meaning there's only a single
write and thus no race condition.

In which case, I wonder if it's worth adding something to the FAQ/BLODA
about this?  I guess not, at least until someone independently encounters
this behaviour so it warrants the "F" as well as the "AQ".

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]