[libc-commits] [libc] [libc] Implement killpg (PR #237561)

Alexey Samsonov via libc-commits libc-commits at lists.llvm.org
Sun Nov 1 08:21:12 PST 2026


================
@@ -0,0 +1,25 @@
+//===-- Linux implementation of killpg ------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/signal/killpg.h"
+
+#include "hdr/errno_macros.h"
+#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
+#include "src/__support/macros/config.h"
+#include "src/signal/kill.h"
+
+namespace LIBC_NAMESPACE_DECL {
+LLVM_LIBC_FUNCTION(int, killpg, (pid_t pgrp, int sig)) {
+  if (pgrp < 0) {
+    libc_errno = EINVAL;
+    return -1;
+  }
+  return LIBC_NAMESPACE::kill(-pgrp, sig);
----------------
vonosmas wrote:

LLVM-libc entrypoints are *not allowed* to depend on other entrypoint functions: https://libc.llvm.org/dev/entrypoints.html#add-entrypoint-object
i.e. you can't call function "kill" from "killpg" implementation. Instead, you have to invoke
the `kill` Linux syscall directly, and handle its return value properly. I would
recommend to refactor "kill" syscall based on the newer recommendations in
https://libc.llvm.org/dev/syscall_wrapper_refactor.html#syscall-wrapper-refactoring
as a first step and a separate PR.

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


More information about the libc-commits mailing list