diff options
author | Eric Andersen <andersen@codepoet.org> | 2002-01-02 12:18:50 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2002-01-02 12:18:50 +0000 |
commit | b88ff80f703931b368d27ebd898accdae5b31e60 (patch) | |
tree | 79aa8e4d9b249e165973423a04fb3b4889308aa3 /libc/signal/sigblock.c | |
parent | cac4a2ef934d7ac5314c874b88b62e922fc70690 (diff) |
Once again, rework the signal handling to be even more correct. We no
longer segfault when running test/signal/sigchld.c, which exposed a bit
of a rats nest. The problem ended up being a erroneous syscall
defination, but in the process of finding that out, I scrubbed things
up nicely and adapted things to use the rt_ signals if they are
available. This now passes all the signal tests.
-Erik
Diffstat (limited to 'libc/signal/sigblock.c')
-rw-r--r-- | libc/signal/sigblock.c | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/libc/signal/sigblock.c b/libc/signal/sigblock.c index f47b75804..1d673f454 100644 --- a/libc/signal/sigblock.c +++ b/libc/signal/sigblock.c @@ -21,36 +21,35 @@ #include <signal.h> /* Block signals in MASK, returning the old mask. */ -int sigblock (mask) - int mask; +int sigblock (int mask) { - register unsigned int sig; - sigset_t set, oset; - - if (__sigemptyset (&set) < 0) - return -1; - - if (sizeof (mask) == sizeof (set)) - *(int *) &set = mask; - else if (sizeof (unsigned long int) == sizeof (set)) - *(unsigned long int *) &set = (unsigned int) mask; - else - for (sig = 1; sig < NSIG && sig <= sizeof (mask) * 8; ++sig) - if ((mask & sigmask (sig)) && __sigaddset (&set, sig) < 0) + register unsigned int sig; + sigset_t set, oset; + + if (__sigemptyset (&set) < 0) return -1; - if (sigprocmask (SIG_BLOCK, &set, &oset) < 0) - return -1; + if (sizeof (mask) == sizeof (set)) + *(int *) &set = mask; + else if (sizeof (unsigned long int) == sizeof (set)) + *(unsigned long int *) &set = (unsigned int) mask; + else + for (sig = 1; sig < NSIG && sig <= sizeof (mask) * 8; ++sig) + if ((mask & sigmask (sig)) && __sigaddset (&set, sig) < 0) + return -1; + + if (sigprocmask (SIG_BLOCK, &set, &oset) < 0) + return -1; - if (sizeof (mask) == sizeof (oset)) - mask = *(int *) &oset; - else if (sizeof (unsigned long int) == sizeof (oset)) - mask = *(unsigned long int*) &oset; - else - for (sig = 1, mask = 0; sig < NSIG && sig <= sizeof (mask) * 8; ++sig) - if (__sigismember (&oset, sig)) - mask |= sigmask (sig); + if (sizeof (mask) == sizeof (oset)) + mask = *(int *) &oset; + else if (sizeof (unsigned long int) == sizeof (oset)) + mask = *(unsigned long int*) &oset; + else + for (sig = 1, mask = 0; sig < NSIG && sig <= sizeof (mask) * 8; ++sig) + if (__sigismember (&oset, sig)) + mask |= sigmask (sig); - return mask; + return mask; } |