LibC: make execvp fail if no executable found
This commit is contained in:
parent
f46240e879
commit
5edbb1d5c4
|
@ -183,7 +183,7 @@ int execve(const char* pathname, char* const argv[], char* const envp[])
|
||||||
int execvp(const char* file, char* const argv[])
|
int execvp(const char* file, char* const argv[])
|
||||||
{
|
{
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
const char* pathname = file;
|
const char* pathname = NULL;
|
||||||
|
|
||||||
// do path resolution if file doesn't contain /
|
// do path resolution if file doesn't contain /
|
||||||
if (strchr(file, '/') == nullptr)
|
if (strchr(file, '/') == nullptr)
|
||||||
|
@ -218,6 +218,16 @@ int execvp(const char* file, char* const argv[])
|
||||||
cur++;
|
cur++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pathname = file;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pathname)
|
||||||
|
{
|
||||||
|
errno = ENOENT;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return execve(pathname, argv, environ);
|
return execve(pathname, argv, environ);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue