Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <753F1E41ACB9D51190C00090277218D80171EE18@WWMESSD206> From: Dolton Tony AB To: "'cygwin AT cygwin DOT com'" Subject: bash script doesn't wait for commands to complete Date: Thu, 9 Sep 2004 16:20:19 +0100 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----_=_NextPart_000_01C49680.843F0780" Note-from-DJ: This may be spam ------_=_NextPart_000_01C49680.843F0780 Content-Type: text/plain; charset="iso-8859-1" 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 ------_=_NextPart_000_01C49680.843F0780 Content-Type: application/octet-stream; name="scr.sh" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="scr.sh" #!/usr/bin/bash for ((i=3D0; i<$1; i++)) do sleep 5 & done for ((i=3D0; i<$2; i++)) do echo $i > file cat file rm file done ------_=_NextPart_000_01C49680.843F0780 Content-Type: text/plain; name="out.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="out.txt" 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 ------_=_NextPart_000_01C49680.843F0780 Content-Type: application/octet-stream; name="cygcheck.out" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="cygcheck.out" Cygwin Configuration Diagnostics Current System Time: Thu Sep 09 13:34:33 2004 Windows NT Ver 4.0 Build 1381 Service Pack 6 Path: C:\cygwin\usr\local\bin C:\cygwin\bin C:\cygwin\bin C:\cygwin\usr\X11R6\bin c:\Perl\bin c:\WINNT\system32 c:\WINNT c:\lbin Output from C:\cygwin\bin\id.exe (nontsec) UID: 12393(doltontony) GID: 10544(mkgroup-l-d) 10544(mkgroup-l-d) Output from C:\cygwin\bin\id.exe (ntsec) UID: 12393(doltontony) GID: 10544(mkgroup-l-d) 0(root) 544(Administrators) 10544(mkgroup-l-d) SysDir: C:\WINNT\System32 WinDir: C:\WINNT HOME =3D `c:\' MAKE_MODE =3D `unix' PWD =3D `/cygdrive/c/cygwin/home/doltontony' USER =3D `doltontony' COMMONDIR =3D `Common' COMPUTERNAME =3D `DOLTONTONYDEV6' COMSPEC =3D `C:\WINNT\system32\cmd.exe' CVS_RSH =3D `/bin/ssh' DEVTROOT =3D `C:\Rel2Plus\Devt' HOMEDRIVE =3D `C:' HOMEPATH =3D `\' HOSTNAME =3D `doltontonydev6' INFOPATH =3D `/usr/local/info:/usr/info:/usr/share/info:/usr/autotool/devel= /info:/usr/autotool/stable/info:' LOGONSERVER =3D `\\UKD001' MANPATH =3D `/usr/local/man:/usr/man:/usr/share/man:/usr/autotool/devel/man= :' NUMBER_OF_PROCESSORS =3D `1' OLDPWD =3D `/cygdrive/c/cygwin/home' OS2LIBPATH =3D `C:\WINNT\system32\os2\dll;' OS =3D `Windows_NT' PATHEXT =3D `.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH' PRINTER =3D `\\BRA01PRINT\G74_01' PROCESSOR_ARCHITECTURE =3D `x86' PROCESSOR_IDENTIFIER =3D `x86 Family 6 Model 5 Stepping 2, GenuineIntel' PROCESSOR_LEVEL =3D `6' PROCESSOR_REVISION =3D `0502' PROMPT =3D `$P$G' PS1 =3D `\[\033]0;\w\007 \033[32m\]\u@\h \[\033[33m\w\033[0m\] $ ' SHLVL =3D `1' SYSTEMDRIVE =3D `C:' SYSTEMROOT =3D `C:\WINNT' TEMP =3D `C:\TEMP' TERM =3D `cygwin' TMP =3D `C:\TEMP' USERDOMAIN =3D `UK' USERNAME =3D `doltontony' USERPROFILE =3D `C:\WINNT\Profiles\doltontony' WINDIR =3D `C:\WINNT' _ =3D `/usr/bin/cygcheck' POSIXLY_CORRECT =3D `1' HKEY_CURRENT_USER\Software\Cygnus Solutions HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2 HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\Program Options HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2 (default) =3D `/cygdrive' cygdrive flags =3D 0x00000022 HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/ (default) =3D `C:\cygwin' flags =3D 0x0000000a HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/usr/bin (default) =3D `C:\cygwin/bin' flags =3D 0x0000000a HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/usr/lib (default) =3D `C:\cygwin/lib' flags =3D 0x0000000a HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\Program Options a: fd N/A N/A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20 c: hd NTFS 6189Mb 37% CP CS UN PA FC=20=20=20=20=20 d: cd N/A N/A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20 e: net NTFS 17422Mb 77% CP CS UN PA FC=20=20=20=20=20 C:\cygwin / system binmode C:\cygwin/bin /usr/bin system binmode C:\cygwin/lib /usr/lib system binmode . /cygdrive system binmode,cygdrive Found: C:\cygwin\bin\awk.exe Found: C:\cygwin\bin\bash.exe Found: C:\cygwin\bin\cat.exe Found: C:\cygwin\bin\cp.exe Not Found: cpp (good!) Found: C:\cygwin\bin\find.exe Not Found: gcc Not Found: gdb Found: C:\cygwin\bin\grep.exe Not Found: ld Found: C:\cygwin\bin\ls.exe Not Found: make Found: C:\cygwin\bin\mv.exe Found: C:\cygwin\bin\rm.exe Found: C:\cygwin\bin\sed.exe Found: C:\cygwin\bin\sh.exe Found: C:\cygwin\bin\tar.exe 61k 2003/08/09 C:\cygwin\bin\cygbz2-1.dll - os=3D4.0 img=3D1.0 sys=3D4.0 "cygbz2-1.dll" v0.0 ts=3D2003/8/9 7:35 45k 2001/04/25 C:\cygwin\bin\cygform5.dll - os=3D4.0 img=3D1.0 sys=3D4.0 "cygform5.dll" v0.0 ts=3D2001/4/25 6:28 35k 2002/01/09 C:\cygwin\bin\cygform6.dll - os=3D4.0 img=3D1.0 sys=3D4.0 "cygform6.dll" v0.0 ts=3D2002/1/9 6:03 48k 2003/08/09 C:\cygwin\bin\cygform7.dll - os=3D4.0 img=3D1.0 sys=3D4.0 "cygform7.dll" v0.0 ts=3D2003/8/9 10:25 28k 2003/07/20 C:\cygwin\bin\cyggdbm-3.dll - os=3D4.0 img=3D1.0 sys=3D4.0 "cyggdbm-3.dll" v0.0 ts=3D2003/7/20 8:58 30k 2003/08/11 C:\cygwin\bin\cyggdbm-4.dll - os=3D4.0 img=3D1.0 sys=3D4.0 "cyggdbm-4.dll" v0.0 ts=3D2003/8/11 3:12 19k 2003/03/22 C:\cygwin\bin\cyggdbm.dll - os=3D4.0 img=3D1.0 sys=3D4.0 "cyggdbm.dll" v0.0 ts=3D2002/2/20 3:05 15k 2003/07/20 C:\cygwin\bin\cyggdbm_compat-3.dll - os=3D4.0 img=3D1.0 s= ys=3D4.0 "cyggdbm_compat-3.dll" v0.0 ts=3D2003/7/20 9:00 15k 2003/08/11 C:\cygwin\bin\cyggdbm_compat-4.dll - os=3D4.0 img=3D1.0 s= ys=3D4.0 "cyggdbm_compat-4.dll" v0.0 ts=3D2003/8/11 3:13 107k 2004/07/06 C:\cygwin\bin\cyggettextlib-0-14-1.dll - os=3D4.0 img=3D1= .0 sys=3D4.0 "cyggettextlib-0-14-1.dll" v0.0 ts=3D2004/7/6 18:56 17k 2004/07/06 C:\cygwin\bin\cyggettextpo-0.dll - os=3D4.0 img=3D1.0 sys= =3D4.0 "cyggettextpo-0.dll" v0.0 ts=3D2004/7/6 18:56 190k 2004/07/06 C:\cygwin\bin\cyggettextsrc-0-14-1.dll - os=3D4.0 img=3D1= .0 sys=3D4.0 "cyggettextsrc-0-14-1.dll" v0.0 ts=3D2004/7/6 18:56 17k 2001/06/28 C:\cygwin\bin\cyghistory4.dll - os=3D4.0 img=3D1.0 sys=3D= 4.0 "cyghistory4.dll" v0.0 ts=3D2001/1/7 4:34 29k 2003/08/10 C:\cygwin\bin\cyghistory5.dll - os=3D4.0 img=3D1.0 sys=3D= 4.0 "cyghistory5.dll" v0.0 ts=3D2003/8/11 0:16 991k 2004/07/06 C:\cygwin\bin\cygiconv-2.dll - os=3D4.0 img=3D1.0 sys=3D4= .0 "cygiconv-2.dll" v0.0 ts=3D2004/7/6 19:10 22k 2001/12/13 C:\cygwin\bin\cygintl-1.dll - os=3D4.0 img=3D1.0 sys=3D4.0 "cygintl-1.dll" v0.0 ts=3D2001/12/13 9:28 37k 2003/08/10 C:\cygwin\bin\cygintl-2.dll - os=3D4.0 img=3D1.0 sys=3D4.0 "cygintl-2.dll" v0.0 ts=3D2003/8/10 22:50 54k 2004/07/06 C:\cygwin\bin\cygintl-3.dll - os=3D4.0 img=3D1.0 sys=3D4.0 "cygintl-3.dll" v0.0 ts=3D2004/7/6 18:51 26k 2001/04/25 C:\cygwin\bin\cygmenu5.dll - os=3D4.0 img=3D1.0 sys=3D4.0 "cygmenu5.dll" v0.0 ts=3D2001/4/25 6:27 20k 2002/01/09 C:\cygwin\bin\cygmenu6.dll - os=3D4.0 img=3D1.0 sys=3D4.0 "cygmenu6.dll" v0.0 ts=3D2002/1/9 6:03 29k 2003/08/09 C:\cygwin\bin\cygmenu7.dll - os=3D4.0 img=3D1.0 sys=3D4.0 "cygmenu7.dll" v0.0 ts=3D2003/8/9 10:25 156k 2001/04/25 C:\cygwin\bin\cygncurses++5.dll - os=3D4.0 img=3D1.0 sys= =3D4.0 "cygncurses++5.dll" v0.0 ts=3D2001/4/25 6:29 175k 2002/01/09 C:\cygwin\bin\cygncurses++6.dll - os=3D4.0 img=3D1.0 sys= =3D4.0 "cygncurses++6.dll" v0.0 ts=3D2002/1/9 6:03 226k 2001/04/25 C:\cygwin\bin\cygncurses5.dll - os=3D4.0 img=3D1.0 sys=3D= 4.0 "cygncurses5.dll" v0.0 ts=3D2001/4/25 6:17 202k 2002/01/09 C:\cygwin\bin\cygncurses6.dll - os=3D4.0 img=3D1.0 sys=3D= 4.0 "cygncurses6.dll" v0.0 ts=3D2002/1/9 6:03 224k 2003/08/09 C:\cygwin\bin\cygncurses7.dll - os=3D4.0 img=3D1.0 sys=3D= 4.0 "cygncurses7.dll" v0.0 ts=3D2003/8/9 10:24 15k 2001/04/25 C:\cygwin\bin\cygpanel5.dll - os=3D4.0 img=3D1.0 sys=3D4.0 "cygpanel5.dll" v0.0 ts=3D2001/4/25 6:27 12k 2002/01/09 C:\cygwin\bin\cygpanel6.dll - os=3D4.0 img=3D1.0 sys=3D4.0 "cygpanel6.dll" v0.0 ts=3D2002/1/9 6:03 19k 2003/08/09 C:\cygwin\bin\cygpanel7.dll - os=3D4.0 img=3D1.0 sys=3D4.0 "cygpanel7.dll" v0.0 ts=3D2003/8/9 10:24 62k 2003/12/11 C:\cygwin\bin\cygpcre-0.dll - os=3D4.0 img=3D1.0 sys=3D4.0 "cygpcre-0.dll" v0.0 ts=3D2003/12/11 17:01 63k 2003/04/11 C:\cygwin\bin\cygpcre.dll - os=3D4.0 img=3D1.0 sys=3D4.0 "cygpcre.dll" v0.0 ts=3D2003/4/11 9:31 9k 2003/12/11 C:\cygwin\bin\cygpcreposix-0.dll - os=3D4.0 img=3D1.0 sys= =3D4.0 "cygpcreposix-0.dll" v0.0 ts=3D2003/12/11 17:01 61k 2003/04/11 C:\cygwin\bin\cygpcreposix.dll - os=3D4.0 img=3D1.0 sys= =3D4.0 "cygpcreposix.dll" v0.0 ts=3D2003/4/11 9:31 108k 2001/06/28 C:\cygwin\bin\cygreadline4.dll - os=3D4.0 img=3D1.0 sys= =3D4.0 "cygreadline4.dll" v0.0 ts=3D2001/1/7 4:34 148k 2003/08/10 C:\cygwin\bin\cygreadline5.dll - os=3D4.0 img=3D1.0 sys= =3D4.0 "cygreadline5.dll" v0.0 ts=3D2003/8/11 0:16 61k 2003/12/04 C:\cygwin\bin\cygz.dll - os=3D4.0 img=3D1.0 sys=3D4.0 "cygz.dll" v0.0 ts=3D2003/12/4 3:03 1111k 2004/09/05 C:\cygwin\bin\cygwin1.dll - os=3D4.0 img=3D1.0 sys=3D4.0 "cygwin1.dll" v0.0 ts=3D2004/9/5 4:17 Cygwin DLL version info: DLL version: 1.5.11 DLL epoch: 19 DLL bad signal mask: 19005 DLL old termios: 5 DLL malloc env: 28 API major: 0 API minor: 116 Shared data: 4 DLL identifier: cygwin1 Mount registry: 2 Cygnus registry name: Cygnus Solutions Cygwin registry name: Cygwin Program options name: Program Options Cygwin mount registry name: mounts v2 Cygdrive flags: cygdrive flags Cygdrive prefix: cygdrive prefix Cygdrive default prefix:=20 Build date: Sat Sep 4 23:17:09 EDT 2004 Shared id: cygwin1S4 Cygwin Package Information Last downloaded files to: C:\TEMP Last downloaded files from: ftp://sunsite.dk/mirrors/cygwin Package Version=20=20=20=20=20=20=20=20=20=20=20=20 _update-info-dir 00227-1=20=20=20=20=20=20=20=20=20=20=20=20 ash 20040127-1=20=20=20=20=20=20=20=20=20 base-files 3.0-3=20=20=20=20=20=20=20=20=20=20=20=20=20=20 base-passwd 2.0-1=20=20=20=20=20=20=20=20=20=20=20=20=20=20 bash 2.05b-16=20=20=20=20=20=20=20=20=20=20=20 bzip2 1.0.2-5=20=20=20=20=20=20=20=20=20=20=20=20 cygwin 1.5.11-1=20=20=20=20=20=20=20=20=20=20=20 diffutils 2.8.7-1=20=20=20=20=20=20=20=20=20=20=20=20 editrights 1.01-1=20=20=20=20=20=20=20=20=20=20=20=20=20 fileutils 4.1-2=20=20=20=20=20=20=20=20=20=20=20=20=20=20 findutils 4.1.7-4=20=20=20=20=20=20=20=20=20=20=20=20 gawk 3.1.4-3=20=20=20=20=20=20=20=20=20=20=20=20 gdbm 1.8.3-7=20=20=20=20=20=20=20=20=20=20=20=20 grep 2.5-1=20=20=20=20=20=20=20=20=20=20=20=20=20=20 groff 1.18.1-2=20=20=20=20=20=20=20=20=20=20=20 gzip 1.3.5-1=20=20=20=20=20=20=20=20=20=20=20=20 less 381-1=20=20=20=20=20=20=20=20=20=20=20=20=20=20 libbz2_1 1.0.2-5=20=20=20=20=20=20=20=20=20=20=20=20 libgdbm 1.8.0-5=20=20=20=20=20=20=20=20=20=20=20=20 libgdbm-devel 1.8.3-7=20=20=20=20=20=20=20=20=20=20=20=20 libgdbm3 1.8.3-3=20=20=20=20=20=20=20=20=20=20=20=20 libgdbm4 1.8.3-7=20=20=20=20=20=20=20=20=20=20=20=20 libgettextpo0 0.14.1-1=20=20=20=20=20=20=20=20=20=20=20 libiconv2 1.9.2-1=20=20=20=20=20=20=20=20=20=20=20=20 libintl1 0.10.40-1=20=20=20=20=20=20=20=20=20=20 libintl2 0.12.1-3=20=20=20=20=20=20=20=20=20=20=20 libintl3 0.14.1-1=20=20=20=20=20=20=20=20=20=20=20 libncurses5 5.2-1=20=20=20=20=20=20=20=20=20=20=20=20=20=20 libncurses6 5.2-8=20=20=20=20=20=20=20=20=20=20=20=20=20=20 libncurses7 5.3-4=20=20=20=20=20=20=20=20=20=20=20=20=20=20 libpcre 4.1-1=20=20=20=20=20=20=20=20=20=20=20=20=20=20 libpcre0 4.5-1=20=20=20=20=20=20=20=20=20=20=20=20=20=20 libreadline4 4.1-2=20=20=20=20=20=20=20=20=20=20=20=20=20=20 libreadline5 4.3-5=20=20=20=20=20=20=20=20=20=20=20=20=20=20 login 1.9-7=20=20=20=20=20=20=20=20=20=20=20=20=20=20 man 1.5k-3=20=20=20=20=20=20=20=20=20=20=20=20=20 mktemp 1.5-3=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ncurses 5.3-4=20=20=20=20=20=20=20=20=20=20=20=20=20=20 readline 4.3-5=20=20=20=20=20=20=20=20=20=20=20=20=20=20 sed 4.1.2-1=20=20=20=20=20=20=20=20=20=20=20=20 sh-utils 2.0.15-4=20=20=20=20=20=20=20=20=20=20=20 tar 1.13.25-5=20=20=20=20=20=20=20=20=20=20 termcap 20021106-2=20=20=20=20=20=20=20=20=20 terminfo 5.3_20030726-1=20=20=20=20=20 texinfo 4.2-4=20=20=20=20=20=20=20=20=20=20=20=20=20=20 textutils 2.0.21-1=20=20=20=20=20=20=20=20=20=20=20 which 1.5-2=20=20=20=20=20=20=20=20=20=20=20=20=20=20 zlib 1.2.1-1=20=20=20=20=20=20=20=20=20=20=20=20 Use -h to see help about each section ------_=_NextPart_000_01C49680.843F0780 Content-Type: text/plain; charset=us-ascii -- 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/ ------_=_NextPart_000_01C49680.843F0780--