diff --git a/src/system/libroot/posix/unistd/exec.cpp b/src/system/libroot/posix/unistd/exec.cpp index 77e98f771c..4cc631820b 100644 --- a/src/system/libroot/posix/unistd/exec.cpp +++ b/src/system/libroot/posix/unistd/exec.cpp @@ -164,6 +164,11 @@ execvp(const char *file, char* const* argv) strcat(path, "/"); strcat(path, file); + // check whether it is a file + struct stat st; + if (stat(path, &st) != 0 || !S_ISREG(st.st_mode)) + continue; + // if executable, execute it if (access(path, X_OK) == 0) return do_exec(path, argv, environ, true);