This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Shell script loop runs out of memory

Thrall, Bryan <bryan.thrall <at>> 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?


Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]