1 //===-- Linux implementation of kill --------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "src/signal/kill.h"
11 #include "src/__support/OSUtil/syscall.h" // For internal syscall function.
12 #include "src/__support/common.h"
13 #include "src/__support/macros/config.h"
14 #include "src/errno/libc_errno.h"
15 #include "src/signal/linux/signal_utils.h"
18 #include <sys/syscall.h> // For syscall numbers.
20 namespace LIBC_NAMESPACE_DECL
{
22 LLVM_LIBC_FUNCTION(int, kill
, (pid_t pid
, int sig
)) {
23 int ret
= LIBC_NAMESPACE::syscall_impl
<int>(SYS_kill
, pid
, sig
);
25 // A negative return value indicates an error with the magnitude of the
26 // value being the error code.
28 libc_errno
= (ret
> 0 ? ret
: -ret
);
32 return ret
; // always 0
35 } // namespace LIBC_NAMESPACE_DECL