delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2015/02/12/17:05:47

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:reply-to:message-id:to:subject
:in-reply-to:references:mime-version:content-type
:content-transfer-encoding; q=dns; s=default; b=Jouqk9Xwz5k/QASL
adV4BOJuRa7tXqzEhQR9rAX8Ob/0fdY6RdRyfpG5dXskN8ZnfYke13o6KBGmaKRg
98XHhBeweORUPQW4cUf3m/zFKvsKqS5gkYAOG87bmqSNhVZC+cqEtxt2OviVMrg0
+PYGFgf7Q5pUZtf2A7x6p73p6Vw=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:reply-to:message-id:to:subject
:in-reply-to:references:mime-version:content-type
:content-transfer-encoding; s=default; bh=9mMZMMCubCHYRkB3+9Cg4i
8TJTA=; b=hWxxmjdMnMB3wWarHOm2YE6kk/FOQ47/stnCJ4TnoP82DFrCYO3KHL
smiCZOxPduNUat0WwDGu5ysctHWOM74AcKAugE60O+bdMa2tFtr2D5k8Kl4vh9EP
Q8NWluqyTs5DwJQyyC/uSW+pacFLdrHueP55sTiTa1gAluuQ3NM/A=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=1.7 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,KAM_BODY_URIBL_PCCC,KAM_FROM_URIBL_PCCC,KAM_THEBAT,MIME_BASE64_BLANKS,SPF_SOFTFAIL autolearn=no version=3.3.2
X-HELO: smtp.ht-systems.ru
Date: Fri, 13 Feb 2015 00:51:02 +0300
From: Andrey Repin <anrdaemon AT yandex DOT ru>
Reply-To: cygwin AT cygwin DOT com
Message-ID: <925263616.20150213005102@yandex.ru>
To: Corinna Vinschen <cygwin AT cygwin DOT com>, cygwin AT cygwin DOT com
Subject: Re: Writing to /dev/clipboard from multiple processes in Bash gives inconsistent behaviour
In-Reply-To: <20150212170342.GB7818@calimero.vinschen.de>
References: <20150212134550 DOT GC20741 AT dinwoodie DOT org> <20150212170342 DOT GB7818 AT calimero DOT vinschen DOT de>
MIME-Version: 1.0
X-IsSubscribed: yes
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id t1CM5hBF003001

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 AT yandex DOT ru) 12.02.2015, <23:56>

Sorry for my terrible english...

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019