]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commitdiff
feat: ulibc signal.h with raise(), kill(), sigprocmask() and POSIX signal constants
authorTulio A M Mendes <[email protected]>
Thu, 12 Feb 2026 02:36:01 +0000 (23:36 -0300)
committerTulio A M Mendes <[email protected]>
Fri, 13 Feb 2026 02:20:50 +0000 (23:20 -0300)
user/ulibc/include/signal.h [new file with mode: 0644]
user/ulibc/src/signal.c [new file with mode: 0644]

diff --git a/user/ulibc/include/signal.h b/user/ulibc/include/signal.h
new file mode 100644 (file)
index 0000000..dc4b571
--- /dev/null
@@ -0,0 +1,54 @@
+#ifndef ULIBC_SIGNAL_H
+#define ULIBC_SIGNAL_H
+
+#include <stdint.h>
+
+#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 (file)
index 0000000..0bd63c1
--- /dev/null
@@ -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));
+}