Subject: more info on execvp problem
From: Pavel Tsekov <[email-masked]>
To: [email-masked]
Date: Mon, 22 Oct 2001 11:43:32 +0200

Ok, here is what I've found about the execvp problem
I mentiond in an earlier post: 

Assuming the simple execvp invocation and the path at
the end of the message we have a problem. The problem
is introduced by the newlib execvp implementation.

Before searching the path for the executable specified,
execvp checks if the path is posix or win32 style, which
involves checking the content of the PATH environment
variable for the semicolon character and also checking
if the contents of the PATH starts with a single letter
followed by a semicolon (dos style drive) - cygwin_posix_path_list_p.

Based on the result of cygwin_posix_path_list_p execvp
decides which symbol to use as a path separator - semi-
colon for win32 style path or colon for posix style path.

Now assume the following PATH string converted to posix -
since on application startup, if the user hasnt modified
the PATH by himself, the PATH is posix style:

PATH=c:/jdk1.3.1/bin:/usr/local/bin:...:c:/usr/local/emacs/bin

The starting 'c' in the path looks like drive to execvp so it
decides to set the path separator to semicolon which is not
actually present in the path string - so when parsing the path 
execvp will threat the whole path as a single entity and 
passing to execv a file path like this:

c:/jdk1.3.1/bin:/usr/local/bin:...:c:/usr/local/emacs/bin/vi

:)

I'll suggest the attached patch although I know it is a bit
incomplete... sigh .. perhaps someone will come with a better
one. However I think the best way to fix this is too assure
that the path is always only posix style or only win32 style -
mixed style path will be very difficult to handle - to keep
the path only one of the styles (posix - since initially it's
posix) it's up the programmer in my opinion.

Thanks :)

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

#include <unistd.h>

int main()
{
  char *arg[] = {
    0
  };

  execvp("vi", arg);

  return 0;
}

Path:   c
        /jdk1.3.1/bin
        /usr/local/bin
        /usr/bin
        /bin
        /Oracle/Ora81/bin
        /Program Files/Oracle/jre/1.1.7/bin
        /usr/local/bin
        /usr/bin
        /usr/bin
        /dev/ant/bin
        /WINNT/system32
        /WINNT
        /WINNT/System32/Wbem
        .
        c
        /dev/ant/bin
        c
        /usr/local/emacs/bin

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/