1.5.19-4 exec family of functions find wrong file to execute

Martin linkscrazy@yahoo.com
Mon Jan 23 16:13:00 GMT 2006


I am attempting to invoke a command with
execvp/execlp.  If a file appears in my PATH before
the executable desired and has the same name as the
executable, the first occurrence of the file name is
used as the executable to invoke.  Even though the
first file is NOT marked as executable.

The attached testcase illustrates this.
Here's a simple shell log:

bash-3.00$ gcc test2.c -o test2
bash-3.00$ PATH=/usr/bin:.
bash-3.00$ test2 nopathnoext
NoPathNoExt
bash-3.00$ touch echo
bash-3.00$ ls -l echo
-rw-r--r-- 1 test None 0 Jan 21 15:39 echo
bash-3.00$ test2 nopathnoext
NoPathNoExt
bash-3.00$ PATH=.:/usr/bin
bash-3.00$ test2 nopathnoext
nopathnoext: No such device or address
bash-3.00$ rm -f echo
bash-3.00$ test2 nopathnoext
NoPathNoExt
bash-3.00$ echo garbage > echo
bash-3.00$ test2 nopathnoext
nopathnoext: Permission denied
bash-3.00$ ls -l echo
-rw-r--r-- 1 test None 8 Jan 21 15:40 echo
bash-3.00$ test2 nopathext
NoPathExt
bash-3.00$ test2 path
Path

Is this normal behavior for execlp/execvp?
Shouldn't the execution permission be set in order to
execute it?

Thanks for your help,
Martin


	

	
		
__________________________________________________________ 
Find your next car at http://autos.yahoo.ca
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cygcheck.out
Type: application/octet-stream
Size: 34370 bytes
Desc: 3924260979-cygcheck.out
URL: <http://cygwin.com/pipermail/cygwin/attachments/20060123/5585ee15/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test2.c
Type: application/octet-stream
Size: 1120 bytes
Desc: 2263429771-test2.c
URL: <http://cygwin.com/pipermail/cygwin/attachments/20060123/5585ee15/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test2.sh
Type: application/octet-stream
Size: 261 bytes
Desc: 809292912-test2.sh
URL: <http://cygwin.com/pipermail/cygwin/attachments/20060123/5585ee15/attachment-0002.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