1//===-- Linux implementation of kill --------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "src/signal/kill.h"
10
11#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
12#include "src/__support/common.h"
13#include "src/errno/libc_errno.h"
14#include "src/signal/linux/signal_utils.h"
15
16#include <signal.h>
17#include <sys/syscall.h> // For syscall numbers.
18
19namespace LIBC_NAMESPACE {
20
21LLVM_LIBC_FUNCTION(int, kill, (pid_t pid, int sig)) {
22 int ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_kill, ts: pid, ts: sig);
23
24 // A negative return value indicates an error with the magnitude of the
25 // value being the error code.
26 if (ret != 0) {
27 libc_errno = (ret > 0 ? ret : -ret);
28 return -1;
29 }
30
31 return ret; // always 0
32}
33
34} // namespace LIBC_NAMESPACE
35

source code of libc/src/signal/linux/kill.cpp