Merge "Fix execvp/execvpe behavior with absolute paths and ENOEXEC."

This commit is contained in:
Elliott Hughes 2016-08-26 16:14:52 +00:00 committed by Gerrit Code Review
commit 6395a3047a
2 changed files with 11 additions and 1 deletions

View file

@ -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 (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.

View file

@ -1272,3 +1272,12 @@ TEST(UNISTD_TEST, execvpe_ENOEXEC) {
// implementation.
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);
}