delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2015/09/23/05:15:54

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: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 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=-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 AT cygwin DOT com
References: <56025A43 DOT 9000604 AT null DOT net>
From: Marco Atzeri <marco DOT atzeri AT gmail DOT 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>
X-IsSubscribed: yes


On 23/09/2015 09:52, litter AT null DOT 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

- Raw text -


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