Fix execvp/execvpe behavior with absolute paths and ENOEXEC.
Bug: http://b/31091962
Change-Id: Id0b3d41868f5e3ed1ccf618bfefb46609367bc9a
diff --git a/libc/bionic/exec.cpp b/libc/bionic/exec.cpp
index 354f931..c43eb90 100644
--- a/libc/bionic/exec.cpp
+++ b/libc/bionic/exec.cpp
@@ -115,7 +115,8 @@
// 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.