[libc-commits] [libc] [libc] Implement execl (PR #220326)

Pavel Labath via libc-commits libc-commits at lists.llvm.org
Thu Sep 3 23:14:18 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 execl
+///
+//===----------------------------------------------------------------------===//
+
+#include "src/unistd/execl.h"
+
+#include "hdr/types/size_t.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/unistd/environ.h"
+
+#include <stdarg.h>
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(int, execl, (const char *path, const char *arg0, ...)) {
+  if (arg0 == nullptr) {
----------------
labath wrote:

> IMO it pretty explicitly states that arg0 can't be a nullptr. However, the same is said for the argv[0] argument of exec functions, so I suspect that @labath means those "work in practice", not "supposed to work according to the spec"? 

Yes, I meant "works in practice". :)

It looks like no major (glibc, musl, bionic) implementation of musl handles a nullptr argv[0] in execl, so I don't think we need to either. But I think it would be a good idea to add LIBC_CRASH_ON_NULLPTR there.

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


More information about the libc-commits mailing list