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

Ooops, sorry.. I forgot to attach the patch :)

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

--- execvp.c.ORIG	Mon Oct 22 11:13:55 2001
+++ execvp.c	Mon Oct 22 11:35:21 2001
@@ -11,12 +11,7 @@
 #include <errno.h>
 #include <ctype.h>
 
-#ifdef __CYGWIN32__
-static char path_delim;
-#define PATH_DELIM path_delim
-#else
 #define PATH_DELIM ':'
-#endif
 
 /*
  * Copy string, until c or <nul> is encountered.
@@ -45,6 +40,10 @@ _DEFUN (execvp, (file, argv),
 {
   char *path = getenv ("PATH");
   char buf[MAXNAMLEN];
+#ifdef __CYGWIN32__
+  int posix_path_len;
+  char *posix_path = 0;
+#endif
 
   /* If $PATH doesn't exist, just pass FILE on unchanged.  */
   if (!path)
@@ -68,7 +67,13 @@ _DEFUN (execvp, (file, argv),
 #endif
 
 #ifdef __CYGWIN32__
-  path_delim = cygwin_posix_path_list_p (path) ? ':' : ';';
+  if (strchr (path, ';'))
+    {
+      posix_path_len = cygwin_win32_to_posix_path_list_buf_size (path);
+      posix_path = (char *) malloc (posix_path_len);
+      cygwin_win32_to_posix_path_list (path, posix_path);
+      path = posix_path;
+    }
 #endif
 
   while (*path)
@@ -79,12 +84,17 @@ _DEFUN (execvp, (file, argv),
 	strcat (buf, "/");
       strcat (buf, file);
       if (execv (buf, argv) == -1 && errno != ENOENT)
-	return -1;
+	break;
       while (*path && *path != PATH_DELIM)
 	path++;
       if (*path == PATH_DELIM)
 	path++;			/* skip over delim */
     }
+
+#ifdef __CYGWIN32__
+  if (posix_path)
+    free (posix_path);
+#endif
 
   return -1;
 }

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