1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- #include <errno.h>
- #define __need_NULL
- #include <stddef.h>
- #include <signal.h>
- #include <string.h>
- __sighandler_t sigset (int sig, __sighandler_t disp)
- {
- struct sigaction act, oact;
- sigset_t set;
-
- if (disp == SIG_ERR || sig < 1 || sig >= NSIG)
- {
- __set_errno (EINVAL);
- return SIG_ERR;
- }
- #ifdef SIG_HOLD
-
- if (disp == SIG_HOLD)
- {
- __sigemptyset (&set);
- __sigaddset (&set, sig);
-
- sigprocmask (SIG_BLOCK, &set, NULL);
- return SIG_HOLD;
- }
- #endif
- memset(&act, 0, sizeof(act));
- act.sa_handler = disp;
-
- if (sigaction (sig, &act, &oact) < 0)
- return SIG_ERR;
-
- __sigemptyset (&set);
- __sigaddset (&set, sig);
-
- sigprocmask (SIG_UNBLOCK, &set, NULL);
- return oact.sa_handler;
- }
|