From: Tulio A M Mendes Date: Thu, 12 Feb 2026 02:36:01 +0000 (-0300) Subject: feat: ulibc signal.h with raise(), kill(), sigprocmask() and POSIX signal constants X-Git-Url: https://projects.tadryanom.me/sitemap.xml?a=commitdiff_plain;h=3685b20cacbdc4578abaff9b26844cdd65ba29f8;p=AdrOS.git feat: ulibc signal.h with raise(), kill(), sigprocmask() and POSIX signal constants --- diff --git a/user/ulibc/include/signal.h b/user/ulibc/include/signal.h new file mode 100644 index 0000000..dc4b571 --- /dev/null +++ b/user/ulibc/include/signal.h @@ -0,0 +1,54 @@ +#ifndef ULIBC_SIGNAL_H +#define ULIBC_SIGNAL_H + +#include + +#define SIGHUP 1 +#define SIGINT 2 +#define SIGQUIT 3 +#define SIGILL 4 +#define SIGTRAP 5 +#define SIGABRT 6 +#define SIGBUS 7 +#define SIGFPE 8 +#define SIGKILL 9 +#define SIGUSR1 10 +#define SIGSEGV 11 +#define SIGUSR2 12 +#define SIGPIPE 13 +#define SIGALRM 14 +#define SIGTERM 15 +#define SIGCHLD 17 +#define SIGCONT 18 +#define SIGSTOP 19 +#define SIGTSTP 20 +#define SIGTTIN 21 +#define SIGTTOU 22 + +#define SA_SIGINFO 0x00000004U + +#define SIG_DFL ((void (*)(int))0) +#define SIG_IGN ((void (*)(int))1) + +struct sigaction { + uintptr_t sa_handler; + uintptr_t sa_sigaction; + uint32_t sa_mask; + uint32_t sa_flags; +}; + +struct siginfo { + int si_signo; + int si_code; + void* si_addr; +}; + +typedef struct siginfo siginfo_t; + +int kill(int pid, int sig); +int raise(int sig); +int sigaction(int signum, const struct sigaction* act, + struct sigaction* oldact); +int sigprocmask(int how, const uint32_t* set, uint32_t* oldset); + +#endif diff --git a/user/ulibc/src/signal.c b/user/ulibc/src/signal.c new file mode 100644 index 0000000..0bd63c1 --- /dev/null +++ b/user/ulibc/src/signal.c @@ -0,0 +1,15 @@ +#include "signal.h" +#include "syscall.h" +#include "errno.h" + +int kill(int pid, int sig) { + return __syscall_ret(_syscall2(SYS_KILL, pid, sig)); +} + +int raise(int sig) { + return kill(_syscall0(SYS_GETPID), sig); +} + +int sigprocmask(int how, const uint32_t* set, uint32_t* oldset) { + return __syscall_ret(_syscall3(SYS_SIGPROCMASK, how, (int)set, (int)oldset)); +}