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]

bash script doesn't wait for commands to complete


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

Attachment: scr.sh
Description: Binary data

Attachment: out.txt
Description: Text document

Attachment: cygcheck.out
Description: Binary data

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

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