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=OV0K2JO6KUsAo194
	H9NZWLnLF845YmxwguVeg6FnamIAj9mWUFGf/iHCPQtDnwYfEQZJ9UkreJJBAlWX
	RYwRJ960z+vx0AQpxsovkfJoeT2dZohzpatkYCyhGRnPqVKqn5urjgGJMklPB/rL
	OzwtSEmi2XJyNWC+3vVVwA5gQG0=
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=Ey372lR4vARocKe7S9VJZz
	/Pz2A=; b=CMsiSI7nM/T0zxXsX/eYuilUas/+G4p6ZaWdupc6yZZVGr9vmF80L1
	7WEsJ1N18EQjtsspjo5wxbc/X6hk/62iQgInxJaJaifwnlXXs0klp+DCMioNv5QR
	KmkkWVZMjy31U7YXkNrATpiZRvQOn7xBvY22CSoSUEDrETU2fqJzE=
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=-2.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2
X-HELO: mail-qk0-f181.google.com
X-Received: by 10.55.26.35 with SMTP id a35mr33326467qka.99.1442999732109;        Wed, 23 Sep 2015 02:15:32 -0700 (PDT)
Subject: Re: Cygwin bash for loops : repeated errors : [main] bash 1972 fork: child -1 - CreateProcessW failed for <bash.exe> errno 9 bash: fork: Bad file descriptor
To: cygwin@cygwin.com
References: <56025A43.9000604@null.net>
From: Marco Atzeri <marco.atzeri@gmail.com>
Message-ID: <56026DAF.2050309@gmail.com>
Date: Wed, 23 Sep 2015 11:15:27 +0200
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0
MIME-Version: 1.0
In-Reply-To: <56025A43.9000604@null.net>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-IsSubscribed: yes



On 23/09/2015 09:52, litter@null.net wrote:
> Hi all,
>
> On a Windows XP 32 bit machine with latest Cygwin installed
> (CYGWIN_NT-5.1 <machine> 2.2.1(0.289/5/3) 2015-08-20 11:40 i686 Cygwin)
> I frequently encounter errors which break bash while loops, making it practically unusable
>
> e.g.
> cat some-file | while read i;do grep text $i;done
>
> results in
> 2 [main] bash 1972 fork: child -1 - CreateProcessW failed for '<cygwin install path>\bin\bash.exe', errno 9
> bash: fork: Bad file descriptor
>
> The error is unpredictable, in a next run everything can run fine again.
>
> I already checked for some common errors, but could not find anything.
>
> Any help is appreciated.
>
> Thanks,
> Paul
>

It seems a race problem, due to the repetitive fork of grep
for every line of some-file

I suggest to rethink the command.

   awk '{if ($1 ~ /text/) print $1}' some-file

Regards
Marco

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

