This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: Writing to /dev/clipboard from multiple processes in Bash gives inconsistent behaviour
- From: Andrey Repin <anrdaemon at yandex dot ru>
- To: Corinna Vinschen <cygwin at cygwin dot com>, cygwin at cygwin dot com
- Date: Fri, 13 Feb 2015 00:51:02 +0300
- Subject: Re: Writing to /dev/clipboard from multiple processes in Bash gives inconsistent behaviour
- Authentication-results: sourceware.org; auth=none
- References: <20150212134550 dot GC20741 at dinwoodie dot org> <20150212170342 dot GB7818 at calimero dot vinschen dot de>
- Reply-to: cygwin at cygwin dot com
Greetings, Corinna Vinschen!
> On Feb 12 13:45, Adam Dinwoodie wrote:
>> I've spotted some slightly odd behaviour when writing things from
>> multiple processes to /dev/clipboard.
>>
>> Easiest to show this with an example:
>>
>> for n in {1..10}; do echo $n; done >/dev/clipboard; cat /dev/clipboard
>>
>> I expect this to print out the numbers 1â10 to the terminal. Sometimes
>> it does, but sometimes it misses out some of the numbers at the end;
>> printing the digits 1â8, say, but no more. Generally it gets to around
>> 7â9, but I've seen it managing to only get up to 3 on one occasion.
> I can't reproduce this. First I tried this manually a couple of times,
> but then I created a loop:
> for i in {1..1000}
> do
> echo > /dev/clipboard
> for n in {1..10}; do echo $n; done > /dev/clipboard
> grep -q 10 /dev/clipboard || cat /dev/clipboard
> done
> and it didn't fail once. I'm not sure what to do if I don't have a
> reproducible testcase...
Failed ~20 times for me. And the more, the more I run the test.
What is more curious, is if I modify your test to only print "1",
while true; do
echo > /dev/clipboard
for n in {1..10}; do echo $n; done > /dev/clipboard
grep -q 10 /dev/clipboard || grep 1 /dev/clipboard
done
it sporadically print 10 !
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;
10
3512
10
6543
10
9468
10
9936
10
12298
--
WBR,
Andrey Repin (anrdaemon@yandex.ru) 12.02.2015, <23:56>
Sorry for my terrible english...