1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 17:26:01 +02:00

Always call pfind() to check the path

This commit is contained in:
Alain Magloire 2002-10-16 00:55:46 +00:00
parent a509b0baaa
commit dbb6aec999

View file

@ -8,7 +8,7 @@
#include <stdlib.h> #include <stdlib.h>
/* from pfind.c */ /* from pfind.c */
char *pfind( char *name ); extern char *pfind(const char *name);
pid_t pid_t
exec0(const char *path, char *const argv[], char *const envp[], exec0(const char *path, char *const argv[], char *const envp[],
@ -19,18 +19,14 @@ exec0(const char *path, char *const argv[], char *const envp[],
char *full_path; char *full_path;
/* /*
* Handle this error case, we need the full path for execve() below. * We use pfind() to check that the program exists and is an executable.
* If not pass the error up. Also execve() wants a full path.
*/ */
if (path[0] != '/' && path[0] != '.') {
full_path = pfind(path); full_path = pfind(path);
//full_path = pathfind (getenv ("PATH"), path, "rx");
if (full_path == NULL) { if (full_path == NULL) {
fprintf(stderr, "Unable to find full path for \"%s\"\n", path ); fprintf(stderr, "Unable to find full path for \"%s\"\n", (path) ? path : "");
return -1; return -1;
} }
} else {
full_path = strdup(path);
}
/* /*
* Make sure we can create our pipes before forking. * Make sure we can create our pipes before forking.