]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commitdiff
feat: sigsuspend syscall (80) — temporarily replace signal mask and block until signa...
authorTulio A M Mendes <[email protected]>
Thu, 12 Feb 2026 03:02:32 +0000 (00:02 -0300)
committerTulio A M Mendes <[email protected]>
Fri, 13 Feb 2026 02:20:50 +0000 (23:20 -0300)
src/kernel/syscall.c
user/ulibc/include/signal.h
user/ulibc/src/signal.c

index 25cd3beb3e41dba3488c1a42f1c936ce69191eb3..5254431555dfbda9c55dfa7fc7dd491c0a2edc88 100644 (file)
@@ -2257,6 +2257,23 @@ void syscall_handler(struct registers* regs) {
         return;
     }
 
+    if (syscall_no == SYSCALL_SIGSUSPEND) {
+        if (!current_process) { regs->eax = (uint32_t)-EINVAL; return; }
+        uint32_t new_mask = 0;
+        if (copy_from_user(&new_mask, (const void*)regs->ebx, sizeof(new_mask)) < 0) {
+            regs->eax = (uint32_t)-EFAULT; return;
+        }
+        uint32_t old_mask = current_process->sig_blocked_mask;
+        current_process->sig_blocked_mask = new_mask;
+        extern void schedule(void);
+        while ((current_process->sig_pending_mask & ~current_process->sig_blocked_mask) == 0) {
+            schedule();
+        }
+        current_process->sig_blocked_mask = old_mask;
+        regs->eax = (uint32_t)-EINTR;
+        return;
+    }
+
     /* ---- Socket syscalls ---- */
     socket_syscall_dispatch(regs, syscall_no);
     /* If socket dispatch handled it, eax is set and we return.
index 02c9f94046c5f4ec6956c8df11e1ba838711cd60..f6816c6de629a1fda8d36ab5a739f8db4b6ace2c 100644 (file)
@@ -51,5 +51,6 @@ int sigaction(int signum, const struct sigaction* act,
               struct sigaction* oldact);
 int sigprocmask(int how, const uint32_t* set, uint32_t* oldset);
 int sigpending(uint32_t* set);
+int sigsuspend(const uint32_t* mask);
 
 #endif
index 0eaa8d0b43cc11d76167821c7e44a6a5383b163a..2b20fa600896f7d500da7e3a754d3f27497e0391 100644 (file)
@@ -17,3 +17,7 @@ int sigprocmask(int how, const uint32_t* set, uint32_t* oldset) {
 int sigpending(uint32_t* set) {
     return __syscall_ret(_syscall1(SYS_SIGPENDING, (int)set));
 }
+
+int sigsuspend(const uint32_t* mask) {
+    return __syscall_ret(_syscall1(SYS_SIGSUSPEND, (int)mask));
+}