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/docs/POSIX_ROADMAP.md?a=commitdiff_plain;h=02ba60d44d0fb778d24908e308e80a91c091c5e7;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 25cd3be..5254431 100644 --- a/src/kernel/syscall.c +++ b/src/kernel/syscall.c @@ -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. diff --git a/user/ulibc/include/signal.h b/user/ulibc/include/signal.h index 02c9f94..f6816c6 100644 --- a/user/ulibc/include/signal.h +++ b/user/ulibc/include/signal.h @@ -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 diff --git a/user/ulibc/src/signal.c b/user/ulibc/src/signal.c index 0eaa8d0..2b20fa6 100644 --- a/user/ulibc/src/signal.c +++ b/user/ulibc/src/signal.c @@ -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)); +}