190158106SMichael Jones //===-- Linux implementation of kill --------------------------------------===// 290158106SMichael Jones // 390158106SMichael Jones // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 490158106SMichael Jones // See https://llvm.org/LICENSE.txt for license information. 590158106SMichael Jones // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 690158106SMichael Jones // 790158106SMichael Jones //===----------------------------------------------------------------------===// 890158106SMichael Jones 990158106SMichael Jones #include "src/signal/kill.h" 1090158106SMichael Jones 1190158106SMichael Jones #include "src/__support/OSUtil/syscall.h" // For internal syscall function. 127abf6c25SSiva Chandra Reddy #include "src/__support/common.h" 13*5ff3ff33SPetr Hosek #include "src/__support/macros/config.h" 147abf6c25SSiva Chandra Reddy #include "src/errno/libc_errno.h" 1590158106SMichael Jones #include "src/signal/linux/signal_utils.h" 1690158106SMichael Jones 1790158106SMichael Jones #include <signal.h> 1890158106SMichael Jones #include <sys/syscall.h> // For syscall numbers. 1990158106SMichael Jones 20*5ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL { 2190158106SMichael Jones 2290158106SMichael Jones LLVM_LIBC_FUNCTION(int, kill, (pid_t pid, int sig)) { 23b6bc9d72SGuillaume Chatelet int ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_kill, pid, sig); 2490158106SMichael Jones 2590158106SMichael Jones // A negative return value indicates an error with the magnitude of the 2690158106SMichael Jones // value being the error code. 2790158106SMichael Jones if (ret != 0) { 287abf6c25SSiva Chandra Reddy libc_errno = (ret > 0 ? ret : -ret); 2990158106SMichael Jones return -1; 3090158106SMichael Jones } 3190158106SMichael Jones 3290158106SMichael Jones return ret; // always 0 3390158106SMichael Jones } 3490158106SMichael Jones 35*5ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL 36