Merge "Fix execvp/execvpe behavior with absolute paths and ENOEXEC."
This commit is contained in:
commit
6395a3047a
2 changed files with 11 additions and 1 deletions
|
@ -115,7 +115,8 @@ int execvpe(const char* name, char* const* argv, char* const* envp) {
|
||||||
|
|
||||||
// If it's an absolute or relative path name, it's easy.
|
// If it's an absolute or relative path name, it's easy.
|
||||||
if (strchr(name, '/') && execve(name, argv, envp) == -1) {
|
if (strchr(name, '/') && execve(name, argv, envp) == -1) {
|
||||||
return __exec_as_script(name, argv, envp);
|
if (errno == ENOEXEC) return __exec_as_script(name, argv, envp);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the path we're searching.
|
// Get the path we're searching.
|
||||||
|
|
|
@ -1272,3 +1272,12 @@ TEST(UNISTD_TEST, execvpe_ENOEXEC) {
|
||||||
// implementation.
|
// implementation.
|
||||||
eth.Run([&]() { execvpe(tf.filename, eth.GetArgs(), eth.GetEnv()); }, 0, "script\n");
|
eth.Run([&]() { execvpe(tf.filename, eth.GetArgs(), eth.GetEnv()); }, 0, "script\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(UNISTD_TEST, execvp_libcore_test_55017) {
|
||||||
|
ExecTestHelper eth;
|
||||||
|
eth.SetArgs({"/system/bin/does-not-exist", nullptr});
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
ASSERT_EQ(-1, execvp("/system/bin/does-not-exist", eth.GetArgs()));
|
||||||
|
ASSERT_EQ(ENOENT, errno);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue