X-Recipient: archive-cygwin@delorie.com
X-SWARE-Spam-Status: No, hits=-5.1 required=5.0	tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,SPF_HELO_PASS,T_RP_MATCHES_RCVD
X-Spam-Check-By: sourceware.org
X-IronPortListener: Outbound_SMTP
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: Av4EAO7b1E+cKEcU/2dsb2JhbABEtFqBB4IZAQEEEihPAgEIDScCEB8TJQEBBBsah2mbR5tekDBgA4x8jheKBoJ8
From: "Buchbinder, Barry (NIH/NIAID) [E]" <BBuchbinder@niaid.nih.gov>
To: "cygwin@cygwin.com" <cygwin@cygwin.com>
Date: Sun, 10 Jun 2012 13:41:25 -0400
Subject: RE: Shell script loop runs out of memory
Message-ID: <0105D5C1E0353146B1B222348B0411A20A770AB442@NIHMLBX02.nih.gov>
References: <loom.20120531T193933-322@post.gmane.org> <CANs8wdBYOBGsmp2iFSSOOd5FZ4qb3i3a-E2EM8LBbPKz=su5Pg@mail.gmail.com> <786EBDA1AC46254B813E200779E7AD36023A42C2@srv1163ex1.flightsafety.com> <loom.20120531T211830-607@post.gmane.org> <0105D5C1E0353146B1B222348B0411A20A770C827D@NIHMLBX02.nih.gov>
In-Reply-To: <0105D5C1E0353146B1B222348B0411A20A770C827D@NIHMLBX02.nih.gov>
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
X-IsSubscribed: yes
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
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id q5AHfnbd028435

Just to complete this topic ...

This gets rid of all the fork-execs in the inner loop except
for sleep.  Instead of comparing file contents, it uses
the test builtin to compare time stamps.

------------------------
#!/bin/dash

FILE_TO_CHECK=/mypath/style.less
COMPARE_FILE=/mypath/compare_file.tmp
echo -n > $COMPARE_FILE

while [ 1 = 1 ]
do
	echo "Waiting for file to change..."
	while [ 1 = 1 ]
	do
		if [ $FILE_TO_CHECK -nt $COMPARE_FILE ]
		then
			break
		fi
		sleep 1
	done
	echo -n > ${COMPARE_FILE}
	echo "File was modified ... Running compiler..."
	/mypath/lessc $FILE_TO_CHECK /mypath/style.css -x
done
------------------------

A question I have is whether using a DOS version of sleep would
avoid the consumption of resources.  In other words, is the
problem caused by the fork-exec or launching a new cygwin
process.  If the latter, might that be avoid by use of a DOS
version of sleep?  (I have one if the OP wants to try it.)

I apologize for taking so long to post this.

- Barry
  Disclaimer:  Statements made herein are not made on behalf of NIAID.

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


