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]

Cygwin 1.5.21 execvp fails when Windows PATH has empty element


A Cygwin program run from cmd.exe fails to invoke another Cygwin via the
PATH, when the PATH contains an empty entry.

A Windows PATH environment variable might contain adjacent ; characters, as
in c:\dir1;;c:\dir2.  This is normally a harmless error.  (For most Windows
programs, an empty entry in the PATH doesn't mean to search the current
directory, as in Unix.)  But this condition seems to cause functions like
execvp to fail with errno==2 under XP Pro SP2.

C:\e>set PATH=c:\cygwin\bin

C:\e>tar czfv foo.tgz *.txt
dumpinfo.txt
foo.jsp.txt

C:\e>set PATH=;c:\cygwin\bin

C:\e>tar czfv foo.tgz *.txt
dumpinfo.txt
tar (child): gzip: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
foo.jsp.txt

The problem isn't specific to tar.  A trivial test program, emptypath.c,
attached, fails with error 2 on its execvp call:

c:\e>set path=;c:\cygwin\bin

c:\e>emptypath ls *.h
execvp failed: No such file or directory

c:\e>set path=c:\cygwin\bin

c:\e>emptypath ls *.h
asm.h [...valid ls output omitted...]

One workaround is to invoke programs via bash, instead of straight from
cmd.exe.  When bash converts the PATH from Windows to Cygwin format, it
deletes these empty elements.  The problem also doesn't occur if the empty
element appears in the PATH after the directory containing the desired
executable.

The problem still occurs if the PATH is set in Unix format:

C:\e>set PATH=:/usr/bin

C:\e>\cygwin\bin\tar czfv foo.tgz *.txt
dumpinfo.txt
tar (child): gzip: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
foo.jsp.txt

C:\e>set PATH=/usr/bin

C:\e>\cygwin\bin\tar czfv foo.tgz *.txt
dumpinfo.txt
foo.jsp.txt

This problem did not occur initially on a second XP Pro SP2 machine running
Cygwin 1.5.19.  Updating that machine to 1.5.21 made the problem appear.

Is this a known bug?  Thanks in advance for any responses.

Steven Doerfler
Lugaru Software, Ltd.
http://www.lugaru.com

Attachment: emptypath.c
Description: Text document

Attachment: cygcheck.out
Description: Text document

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