commit 8038d63a4306f4124dc61ccffe677c2db4468a73 parent 8271dd25175de6b33cf221505273d23b829c0e98 Author: illiliti <illiliti@dimension.sh> Date: Sat, 18 Feb 2023 20:38:12 +0300 unix::signal: add reset and ignore functions one to reset signal to default state and one to ignore signal Implements: https://todo.sr.ht/~sircmpwn/hare/804 Signed-off-by: illiliti <illiliti@dimension.sh> Diffstat:
M | unix/signal/+linux.ha | | | 11 | +++++++++++ |
1 file changed, 11 insertions(+), 0 deletions(-)
diff --git a/unix/signal/+linux.ha b/unix/signal/+linux.ha @@ -61,6 +61,17 @@ export fn restore(signum: signal, action: *sigaction) void = { }; }; +// Unregisters signal handlers for the specified signal. +export fn reset(signum: signal) void = { + handle(signum, rt::SIG_DFL); +}; + +// Prevents given signal from arriving to the current process. +// One common use case is to ignore SIGCHLD to avoid zombie child processes. +export fn ignore(signum: signal) void = { + handle(signum, rt::SIG_IGN); +}; + // Adds the given list of signals to the process's current signal mask, // returning the old signal mask. This is a convenience function around // [[setprocmask]].