delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2012/05/31/15:24:23

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=1.0 required=5.0 tests=AWL,BAYES_00,DKIM_ADSP_CUSTOM_MED,FORGED_YAHOO_RCVD,FREEMAIL_FROM,KHOP_THREADED,NML_ADSP_CUSTOM_MED,RCVD_NUMERIC_HELO,SPF_HELO_PASS,T_RP_MATCHES_RCVD
X-Spam-Check-By: sourceware.org
To: cygwin AT cygwin DOT com
From: Jordan <uptownb0y AT yahoo DOT com>
Subject: Re: Shell script loop runs out of memory
Date: Thu, 31 May 2012 19:23:28 +0000 (UTC)
Lines: 46
Message-ID: <loom.20120531T211830-607@post.gmane.org>
References: <loom DOT 20120531T193933-322 AT post DOT gmane DOT org> <CANs8wdBYOBGsmp2iFSSOOd5FZ4qb3i3a-E2EM8LBbPKz=su5Pg AT mail DOT gmail DOT com> <786EBDA1AC46254B813E200779E7AD36023A42C2 AT srv1163ex1 DOT flightsafety DOT com>
Mime-Version: 1.0
User-Agent: Loom/3.14 (http://gmane.org/)
X-IsSubscribed: yes
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

Thrall, Bryan <bryan.thrall <at> flightsafety.com> writes:
> 
> AZ 9901 wrote on 2012-05-31: 
> > 2012/5/31 Jordan :
> > Then, when (bash) scripting under Cygwin, you must take care to avoid
> > forking as much as possible.
> > 
> > You could try to improve the "sleep 1" loop with the following one :
> > 
> > while md5sum $FILE_TO_CHECK | cut -d " " -f1 | grep -q "^$MD5PRINT$"
> > do
> >   sleep 1
> > done
> > 
> > Note that MD5PRINTNEW is no more useful here.
> > With this loop we avoid the fork done by
> > MD5PRINTNEW=`md5sum $FILE_TO_CHECK | cut -d " " -f1`
> 
> Doesn't that just replace the 2 MD5PRINTNEW  forks (md5sum and cut) with 3 
(md5sum, cut, and grep)?
> 
> Seems like the (untested) following would be better (in terms of fewer forks):
> 
> TMPFILE=$(mktemp)
> md5sum $FILE_TO_CHECK > "$TMPFILE"
> ...
> while md5sum -c "$TMPFILE"
> do
>   sleep 1
> done
> rm "$TMPFILE"
> 

Ok... Two questions for you guys, then:

1.  Does "fewer forks" mean that some forks are still occurring, thus the same 
memory crash will still happen, but not right away?  Just delaying the 
inevitable, for longer than my original script does?

2.  What is this I read about "rebasing" for BLODA-related issues ... Can 
rebasing help me to completely resolve this script problem?  I read the docs 
about "rebase all" but don't understand whether it would be effective for my 
situation.  Or do I just need to close any of the offending software such as 
anti-virus, then reopen CygWin and try my script again?

Thanks!


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