From 656b1dd6be1596e921d775680ff937d1525d8587 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Sat, 11 Dec 2021 21:21:47 +0200 Subject: [PATCH] LibC: Implement sigwait() This is done internally by just calling the more modern sigtimedwait syscall and then massaging the results to fit sigwait's interface. --- Userland/Libraries/LibC/signal.cpp | 11 +++++++++++ Userland/Libraries/LibC/signal.h | 1 + 2 files changed, 12 insertions(+) diff --git a/Userland/Libraries/LibC/signal.cpp b/Userland/Libraries/LibC/signal.cpp index 929935abdb..603f09c07f 100644 --- a/Userland/Libraries/LibC/signal.cpp +++ b/Userland/Libraries/LibC/signal.cpp @@ -163,6 +163,17 @@ int sigsuspend(const sigset_t* set) return pselect(0, nullptr, nullptr, nullptr, nullptr, set); } +// https://pubs.opengroup.org/onlinepubs/009604499/functions/sigwait.html +int sigwait(sigset_t const* set, int* sig) +{ + int rc = syscall(Syscall::SC_sigtimedwait, set, nullptr, nullptr); + VERIFY(rc != 0); + if (rc < 0) + return -rc; + *sig = rc; + return 0; +} + // https://pubs.opengroup.org/onlinepubs/9699919799/functions/sigwaitinfo.html int sigwaitinfo(sigset_t const* set, siginfo_t* info) { diff --git a/Userland/Libraries/LibC/signal.h b/Userland/Libraries/LibC/signal.h index 9a86683f9e..ee1593a113 100644 --- a/Userland/Libraries/LibC/signal.h +++ b/Userland/Libraries/LibC/signal.h @@ -28,6 +28,7 @@ int sigprocmask(int how, const sigset_t* set, sigset_t* old_set); int sigpending(sigset_t*); int sigsuspend(const sigset_t*); int sigtimedwait(sigset_t const*, siginfo_t*, struct timespec const*); +int sigwait(sigset_t const*, int*); int sigwaitinfo(sigset_t const*, siginfo_t*); int raise(int sig); int getsignalbyname(const char*);