bash: slow command execution after permission denied error

Reinhard Nissl rnissl@gmx.de
Mon May 24 12:57:00 GMT 2004


Hi,

I've discovered a strange behaviour of bash on Windows NT and 2000, but not on XP.

Please have a look on the following simple test script named x.sh:

----------------------------------------------------------------------------------

#!./bash

export PATH=`pwd`:$PATH
export CYGWIN=nontsec

while true ; do
	date
	rm -rvf "//merlin/upload/x.sh"
	date
	cp -av "x.sh" "//merlin/upload"
	date
	rm -rvf "//merlin/upload/zplmanual.pdf"
	date
	cp -av "./zplmanual.pdf" "//merlin/upload"
	date
	echo ------------------------
done

----------------------------------------------------------------------------------

All required binaries are located in the same directory, where x.sh resides, 
that's why there is the "export PATH" statement. Furhtermore, I don't want 
cygwin to use NT security.

Then, the script repeatedly prints the current time and executes a command. 
"//merlin/upload" is a share, where the current user has enough rights, so the 
first "rm" and "cp" execute properly. The same is true for the other commands, 
that work on the PDF file (assuming that the PDF file is not opend by anybody 
at that time).

Typically, this script runs fast with multiple iterations per second.


G E T T I N G   S T R A N G E

Now consider the case, where anybody is watching the PDF file on 
"//merlin/upload" with Adobe reader. The second "rm" command remains quiet, 
but takes much longer now to return. The second "cp" command gives a 
"permission denied" error and takes a little bit longer to process too.

That's the behaviour, that one would expect. And one would also expect, that 
at the next iteration, the first "rm" and "cp" command work fast as usual and 
that the second pair takes longer to process.

This is true on Windows XP as the following output for three iterations shows:

----------------------------------------------------------------------------------

C:\HOME>bash -c ./x.sh
Mon May 24 14:06:17     2004
removing `//merlin/upload/x.sh'
Mon May 24 14:06:17     2004
`x.sh' -> `//merlin/upload/x.sh'
Mon May 24 14:06:17     2004
removing `//merlin/upload/zplmanual.pdf'
Mon May 24 14:06:20     2004
`./zplmanual.pdf' -> `//merlin/upload/zplmanual.pdf'
cp: cannot create regular file `//merlin/upload/zplmanual.pdf': Permission denied
Mon May 24 14:06:21     2004
------------------------
Mon May 24 14:06:21     2004
removing `//merlin/upload/x.sh'
Mon May 24 14:06:21     2004
`x.sh' -> `//merlin/upload/x.sh'
Mon May 24 14:06:21     2004
removing `//merlin/upload/zplmanual.pdf'
Mon May 24 14:06:24     2004
`./zplmanual.pdf' -> `//merlin/upload/zplmanual.pdf'
cp: cannot create regular file `//merlin/upload/zplmanual.pdf': Permission denied
Mon May 24 14:06:25     2004
------------------------
Mon May 24 14:06:25     2004
removing `//merlin/upload/x.sh'
Mon May 24 14:06:25     2004
`x.sh' -> `//merlin/upload/x.sh'
Mon May 24 14:06:25     2004
removing `//merlin/upload/zplmanual.pdf'
Mon May 24 14:06:28     2004
`./zplmanual.pdf' -> `//merlin/upload/zplmanual.pdf'
cp: cannot create regular file `//merlin/upload/zplmanual.pdf': Permission denied
Mon May 24 14:06:29     2004
------------------------

----------------------------------------------------------------------------------

But on Windows NT and Windows 2000 it behaves different:

----------------------------------------------------------------------------------

C:\HOME>bash -c ./x.sh
Mon May 24 14:07:58 WEDT 2004
removing `//merlin/upload/x.sh'
Mon May 24 14:07:59 WEDT 2004
`x.sh' -> `//merlin/upload/x.sh'
Mon May 24 14:07:59 WEDT 2004
removing `//merlin/upload/zplmanual.pdf'
Mon May 24 14:08:03 WEDT 2004
`./zplmanual.pdf' -> `//merlin/upload/zplmanual.pdf'
cp: cannot create regular file `//merlin/upload/zplmanual.pdf': Permission denied
Mon May 24 14:08:09 WEDT 2004
------------------------
Mon May 24 14:08:11 WEDT 2004
removing `//merlin/upload/x.sh'
Mon May 24 14:08:15 WEDT 2004
`x.sh' -> `//merlin/upload/x.sh'
Mon May 24 14:08:19 WEDT 2004
removing `//merlin/upload/zplmanual.pdf'
Mon May 24 14:08:24 WEDT 2004
`./zplmanual.pdf' -> `//merlin/upload/zplmanual.pdf'
cp: cannot create regular file `//merlin/upload/zplmanual.pdf': Permission denied
Mon May 24 14:08:30 WEDT 2004
------------------------
Mon May 24 14:08:32 WEDT 2004
removing `//merlin/upload/x.sh'
Mon May 24 14:08:36 WEDT 2004
`x.sh' -> `//merlin/upload/x.sh'
Mon May 24 14:08:40 WEDT 2004
removing `//merlin/upload/zplmanual.pdf'
Mon May 24 14:08:45 WEDT 2004
`./zplmanual.pdf' -> `//merlin/upload/zplmanual.pdf'
cp: cannot create regular file `//merlin/upload/zplmanual.pdf': Permission denied
Mon May 24 14:08:52 WEDT 2004
------------------------

----------------------------------------------------------------------------------

The difference is, that after the first "removing 
`//merlin/upload/zplmanual.pdf'" every other command takes about 4 seconds to 
execute. Please note, that command execution is not that slow in general, 
because the first "rm" and "cp" command of the first iteration work as fast as 
usual.

I hope, this issue is explained precisely enough to be reproduceable by any 
cygwin developer. Currently, I don't know, whether it is an issue of bash or 
any other component of cygwin.

Bye.
-- 
Dipl.-Inform. (FH) Reinhard Nissl
mailto:rnissl@gmx.de



More information about the Cygwin-developers mailing list