[libc-commits] [libc] [libc] Implement execlp in unistd (PR #232901)
Pavel Labath via libc-commits
libc-commits at lists.llvm.org
Thu Oct 22 02:21:28 PDT 2026
================
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Linux implementation of execlp.
+///
+//===----------------------------------------------------------------------===//
+
+#include "src/unistd/execlp.h"
+
+#include "hdr/types/size_t.h"
+#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/null_check.h"
+#include "src/unistd/environ.h"
+#include "src/unistd/linux/exec_utils.h"
+
+#include <stdarg.h>
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(int, execlp, (const char *file, const char *arg0, ...)) {
+ LIBC_CRASH_ON_NULLPTR(file);
+ LIBC_CRASH_ON_NULLPTR(arg0);
+
+ va_list varargs, varargs_copy;
----------------
labath wrote:
This is probably best as a followup patch, but I don't like the idea of a third copy of the va_list->VLA block.
I think we could avoid that by adding something like this to our _utils.h file:
```
// extracts argv and calls exec(argv)
template <typename ExecFn>
LIBC_INLINE ErrorOr<int> exec_with_arg_list(const char *arg0, va_list *args,
ExecFn exec);
```
Would you be up for that?
https://github.com/llvm/llvm-project/pull/232901
More information about the libc-commits
mailing list