Shell script loop runs out of memory
Thu May 31 19:37:00 GMT 2012
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):
> md5sum $FILE_TO_CHECK > "$TMPFILE"
> while md5sum -c "$TMPFILE"
> sleep 1
> 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: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin