From 633feeea57c298306d8664c9c2768ab46fb7c6f4 Mon Sep 17 00:00:00 2001 From: Anton Kling Date: Wed, 11 Dec 2024 18:47:33 +0100 Subject: signal: Remove old way of sending signals and instead use procfs --- userland/libc/signal/kill.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'userland/libc/signal/kill.c') diff --git a/userland/libc/signal/kill.c b/userland/libc/signal/kill.c index c8a368f..4518b49 100644 --- a/userland/libc/signal/kill.c +++ b/userland/libc/signal/kill.c @@ -1,15 +1,20 @@ +#include #include -#include #include +#include #include - -int kill_fd(int fd, int sig) { - RC_ERRNO(syscall(SYS_KILL, fd, sig, 0, 0, 0)) -} +#include int kill(int pid, int sig) { - int fd = open_process(pid); - int rc = kill_fd(fd, sig); - close(fd); - return rc; + char buffer[4096]; + snprintf(buffer, sizeof(buffer), "/proc/%d/signal", pid); + int fd = open(buffer, O_WRITE); + if (-1 == fd) { + return -1; + } + if (-1 == dprintf(fd, "%d", sig)) { + return -1; + } + assert(-1 != close(fd)); + return 0; } -- cgit v1.2.3