bash script doesn't wait for commands to complete

Dolton Tony AB Tony.Dolton@uk.fujitsu.com
Thu Sep 9 15:47:00 GMT 2004


I have a problem whereby a bash script doesn't wait for foreground commands
to complete. The script in question kicks off a number of background
processes, and processes their results as they complete.

A simplified version which exhibits the problem is attached as scr.sh. The
number of background processes and the number of iterations of the
foreground commands are supplied as parameters, (e.g. "./scr.sh 50 100").
These values, as well as the length of the sleep may need adjustment
depending on a machine's performance, to make sure that the sleeps terminate
squarely within the foreground loop.

When several background processes are specified, their exiting appears to
confuse bash into thinking the foreground commands have exited, and it
carries on and invokes the next command before it should. The results are
unpredictable, but involve various "No such file or directory" errors, as
files are accessed after being deleted, deleted twice in a row, etc. A
typical run is shown in out.txt.

When the script is typed in and run from the command line, no errors occur.

Is there a fix to bash (or the Cygwin dll?) that will cure this problem?

I'm currently using version 1.5.11 on a single processor Windows NT
platform, but have had the failure on all other Cygwin versions I've tried,
and on Windows 2000.

Regards,

Tony Dolton
Fujitsu Services

-------------- next part --------------
A non-text attachment was scrubbed...
Name: scr.sh
Type: application/octet-stream
Size: 125 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20040909/5f9e39a9/attachment.obj>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: out.txt
URL: <http://cygwin.com/pipermail/cygwin/attachments/20040909/5f9e39a9/attachment.txt>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cygcheck.out
Type: application/octet-stream
Size: 11121 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20040909/5f9e39a9/attachment-0001.obj>
-------------- next part --------------
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


More information about the Cygwin mailing list