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
scr.sh
Description: Binary data
0 1 2 3 5 5 6 7 cat: file: No such file or directory rm: cannot remove `file': No such file or directory 9 cat: file: No such file or directory rm: cannot remove `file': No such file or directory 11 12 13 cat: file: No such file or directory cat: file: No such file or directory rm: cannot remove `file': No such file or directory 17 17 19 19 rm: cannot remove `file': No such file or directory 20 21 22 23 24 25 26 27 28 29 30 rm: cannot remove `file': No such file or directory 32 32 33 34 35 36 37 cat: file: No such file or directory rm: cannot remove `file': No such file or directory 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 cat: file: No such file or directory rm: cannot remove `file': No such file or directory 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 cat: file: No such file or directory rm: cannot remove `file': No such file or directory 79 80 81 82 83 84 85 86 87 88 89 cat: file: No such file or directory rm: cannot remove `file': No such file or directory 91 92 93 94 95 96 97 cat: file: No such file or directory rm: cannot remove `file': No such file or directory 99
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/