X-Recipient: archive-cygwin@delorie.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:subject:to:references:from:message-id:date
	:mime-version:in-reply-to:content-type
	:content-transfer-encoding; q=dns; s=default; b=XzNUSAmqzID5QI2y
	le35RsJXjO/fd22l/dgYnomWQQ4l8r8HwEA6j1FUZJ3maASb1pOMhsWlaFlUet0v
	duncBxszA2C9cEhQeAFRIoeAgJMpdCnc6rfx8yRVODiMND/LPXTOMfJXAdweihlF
	pWOQANyWefMZUa5jTz5hIjS/k0o=
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:subject:to:references:from:message-id:date
	:mime-version:in-reply-to:content-type
	:content-transfer-encoding; s=default; bh=lp+bI5Lxfj+vtGy2Ldkvhh
	sSOI0=; b=V0rnXUsP6YKCFaKr/tF5idnFqfomrzMLFRQkkTSWuHbAFInh+3Q2/j
	YDg/vW2m41R/lUr6FHsWBG5pYCfOF0SO4zJ6dacGh8X3P7c1J18UQcz8rAukYuvI
	avDi+Y/Uo/BlEoDVNEffcoFT59fbL+tgqThgT7YL8dXZ/Dfr7BstI=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=1.0 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS,TBC autolearn=no version=3.3.2 spammy=txt, Enterprise, edition, hangs
X-HELO: mail-wm0-f48.google.com
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;        d=1e100.net; s=20130820;        h=x-gm-message-state:subject:to:references:from:message-id:date         :user-agent:mime-version:in-reply-to:content-transfer-encoding;        bh=yfjJP7YhevdZlBGe3lCxxfcvd3g9onczno/0AKMPckA=;        b=V+a7igFzaiDQPw36nV3QitdQhHKL4y2ZYplWUBJEnpKbuiGthE/VY+nvQuNDlZ8j5L         pQ7bCSKEJqCUKTDW6DOl3I2TWv2XsqYPkjrLYP+ODo1udmo3/qlcq/oqiP65NUEyrhtV         RQYnANfWPnwqevT5YFeJQ4m5VCZtP87EdkgRpsSJkSRXUgJxrmvnd3/ZB5j5fQR+YnzK         Eyo8g6h73ji2zIDGMod5F0fbh14WSFqj+M+KFisnHzylJvIHJ4Aw9HjYBvY3KyX1b9dm         wilxLW9ZF0Xvz5IUzCjLNTrenfeVRsf4FcHNjnkYa5TKriv9BBWBKwrCww/7ZCBurLzF         r6Lw==
X-Gm-Message-State: AD7BkJIXaqtyLaTh0skQLBHcXAeH9IDUrcNWNCmXjtCjYJmGEfkgcMkA8BAbgGPl0zPsuw==
X-Received: by 10.194.115.196 with SMTP id jq4mr1801701wjb.101.1456494641719;        Fri, 26 Feb 2016 05:50:41 -0800 (PST)
Subject: Re: echo -n or sleep 0 needed to unblock Bourne shell script
To: cygwin@cygwin.com
References: <DUB115-W730C30F47A6696F9686D308AA70@phx.gbl>
From: Marco Atzeri <marco.atzeri@gmail.com>
Message-ID: <56D0582D.1090608@gmail.com>
Date: Fri, 26 Feb 2016 14:50:37 +0100
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0
MIME-Version: 1.0
In-Reply-To: <DUB115-W730C30F47A6696F9686D308AA70@phx.gbl>
Content-Type: text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding: 7bit
X-IsSubscribed: yes



On 26/02/2016 14:04, Matthijs Nescio wrote:
> Hi,
>
> I have the strangest problem. I am running some complicated advanced Bourne shell scripting. These scripts work fine under Ubuntu 14.04 LTS. However, in Cygwin I have to add some strange commands with no obvious effect; without these the scripts just hang. I can not disclose the scripts completely because they are company property. I realise that this does not comply to the rules of smart questions, but if anybody else has this problem the Cygwinners need to know about it. I do not exactly know when these problems started. I reinstalled Cygwin twice, several weeks ago and yesterday evening.
>
> I have had this problem with several complicated, lengthy scripts. Debugging using echo debug statements is hard because the echo makes the problem go away. When I discovered similar problems in multiple scripts, I reinstalled Cygwin, but the problem persists. Also rebooting my Windows 7 Enterprise edition machine does not solve the problem. I have had some experienced colleagues to look at this and they were as flabbergasted as I was.
>
> Examples:
>
>    TTP_FILE_DR_KML=`echo $TTP_FILE.dr.kml | sed -s 's#\.txt\.#\.#g'`
>    #echo -n> /dev/null
>    sleep 0
>    if [ "`convert_needed "$TTP_FILE_DR_KML"`" = "convert" ]
>    then
>
> In the examples above and below, either the sleep or the echo has to be commented in, otherwise the script just hangs. In the example below the doit function needs the echo or sleep, otherwise it does not return.
>
> doit()
> {
>    # 8< code removed
>    #echo -n
>    sleep 0
> }
>
> In
>   order to investigate this problem the Cywinners will need more information. Feel free to ask, but it may not be legal for me to share.
>
> Questions:
> * Was a similar issue ever reported? I have looked, but did not find anything.
> * Is there a solution?
>
> Thank you, kind regards, Matthijs.


I suspect you hit a corner case of resource race.
May be as the time for execution is very short :

$ time echo -n > /dev/null 0

real    0m0.000s
user    0m0.000s
sys     0m0.000s

$ time sleep 0

real    0m0.070s
user    0m0.015s
sys     0m0.062s


As both the two commands are just supposed to waste minimal time,
what was the original need of both of them ?



--
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

