hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 8b3fae59493b2e2c83ba4a71c6d110861a1f1632
parent e1d2e9f64d0234b1f14d305a707468ffbbf5e980
Author: Drew DeVault <sir@cmpwn.com>
Date:   Mon, 11 Apr 2022 17:23:06 +0200

unix::signal: add procmask

Signed-off-by: Drew DeVault <sir@cmpwn.com>

Diffstat:
Munix/signal/+linux.ha | 18++++++++++++++++++
1 file changed, 18 insertions(+), 0 deletions(-)

diff --git a/unix/signal/+linux.ha b/unix/signal/+linux.ha @@ -56,6 +56,24 @@ export fn restore(signum: signal, action: *sigaction) void = { }; }; +// Sets the process's signal mask, returning the previous mask. +export fn procmask(how: how, signals: signal...) sigset = { + let new = newsigset(signals...); + let old = sigset { ... }; + rt::sigprocmask(how, &new, &old)!; + return old; +}; + +// Defines the modes of operation for [[procmask]]. +export type how = enum int { + // Adds the given set of signals to the current mask. + BLOCK = rt::SIG_BLOCK, + // Removes the given set of signals from the current mask. + UNBLOCK = rt::SIG_UNBLOCK, + // Sets the process mask to the given set. + SETMASK = rt::SIG_SETMASK, +}; + export type sigaction = rt::sigact; export type sigset = rt::sigset;