[libc-commits] [libc] [libc] Implement execvpe in unistd (PR #234071)

Aman Maurya via libc-commits libc-commits at lists.llvm.org
Wed Oct 21 06:48:06 PDT 2026


================
@@ -0,0 +1,99 @@
+//===-- Linux implementation helpers for exec -------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_UNISTD_LINUX_EXEC_UTILS_H
+#define LLVM_LIBC_SRC_UNISTD_LINUX_EXEC_UTILS_H
+
+#include "hdr/errno_macros.h"
+#include "hdr/limits_macros.h"
+#include "hdr/types/size_t.h"
+#include "src/__support/CPP/string_view.h"
+#include "src/__support/OSUtil/linux/syscall_wrappers/execve.h"
+#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
+#include "src/__support/macros/config.h"
+#include "src/stdlib/environ_internal.h"
+#include "src/string/memory_utils/inline_memcpy.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace internal {
+
+// TODO: POSIX requires that if execve fails with ENOEXEC, the file is executed
+// using the system shell (as if by `sh -- file args...`). The kernel only
+// handles ELF, "#!" scripts, and binfmt_misc formats, so shebang-less scripts
+// currently fail with ENOEXEC instead of being run by /bin/sh.
+LIBC_INLINE int execvpe(const char *file, char *const argv[],
+                        char *const envp[]) {
+  cpp::string_view file_sv(file);
+  if (file_sv.empty()) {
+    libc_errno = ENOENT;
----------------
amanmaurya92 wrote:

done! updated `internal::execvpe`

https://github.com/llvm/llvm-project/pull/234071


More information about the libc-commits mailing list