#ifdef HAVE_CONFIG_H #include #endif #include #include #include "../internal/syscall.h" /* * kill/killpg: process- and process-group-directed signals over SYS_kill. * * kill passes its pid straight to the kernel, which interprets it exactly * as POSIX specifies: pid > 0 is a single process, pid == 0 the caller's * process group, pid == -1 every process the caller may signal, and * pid < -1 the process group -pid. killpg(pgrp, sig) is equivalent to * kill(-pgrp, sig): a negative pgrp is not a valid group id and is * rejected with EINVAL here (mirroring musl) rather than inverted into a * positive-pid send by accident. */ int kill(pid_t pid, int sig) { return syscall_ret(__syscall2(SYS_kill, (long)pid, sig)); } int killpg(pid_t pgrp, int sig) { if (pgrp < 0) { errno = EINVAL; return -1; } return kill(-pgrp, sig); }