]> git.proxmox.com Git - wasi-libc.git/blame - libc-top-half/musl/src/signal/sigset.c
Update to musl 1.1.23.
[wasi-libc.git] / libc-top-half / musl / src / signal / sigset.c
CommitLineData
320054e8
DG
1#include <signal.h>
2
3void (*sigset(int sig, void (*handler)(int)))(int)
4{
5 struct sigaction sa, sa_old;
d4db3fa2 6 sigset_t mask, mask_old;
320054e8
DG
7
8 sigemptyset(&mask);
9 if (sigaddset(&mask, sig) < 0)
10 return SIG_ERR;
11
12 if (handler == SIG_HOLD) {
13 if (sigaction(sig, 0, &sa_old) < 0)
14 return SIG_ERR;
d4db3fa2 15 if (sigprocmask(SIG_BLOCK, &mask, &mask_old) < 0)
320054e8
DG
16 return SIG_ERR;
17 } else {
18 sa.sa_handler = handler;
19 sa.sa_flags = 0;
20 sigemptyset(&sa.sa_mask);
21 if (sigaction(sig, &sa, &sa_old) < 0)
22 return SIG_ERR;
d4db3fa2 23 if (sigprocmask(SIG_UNBLOCK, &mask, &mask_old) < 0)
320054e8
DG
24 return SIG_ERR;
25 }
d4db3fa2 26 return sigismember(&mask_old, sig) ? SIG_HOLD : sa_old.sa_handler;
320054e8 27}