From: Tulio A M Mendes Date: Thu, 12 Feb 2026 03:02:32 +0000 (-0300) Subject: feat: sigsuspend syscall (80) — temporarily replace signal mask and block until signa... X-Git-Url: https://projects.tadryanom.me/?a=commitdiff_plain;h=b0d6b02ce20018679959fd40272f3cdf1bda1674;p=AdrOS.git feat: sigsuspend syscall (80) — temporarily replace signal mask and block until signal delivery --- diff --git a/src/kernel/syscall.c b/src/kernel/syscall.c index 949bd5e0..58d46889 100644 --- a/src/kernel/syscall.c +++ b/src/kernel/syscall.c @@ -2266,6 +2266,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. diff --git a/user/ulibc/include/signal.h b/user/ulibc/include/signal.h index d551bddf..64b4a80a 100644 --- a/user/ulibc/include/signal.h +++ b/user/ulibc/include/signal.h @@ -60,5 +60,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 diff --git a/user/ulibc/src/signal.c b/user/ulibc/src/signal.c index 5e45fb4d..1834291a 100644 --- a/user/ulibc/src/signal.c +++ b/user/ulibc/src/signal.c @@ -26,3 +26,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)); +}