signal.c 597 B

1234567891011121314151617181920212223
  1. #include <string.h>
  2. #include <signal.h>
  3. /* Global variable */
  4. sigset_t _sigintr; /* Set by siginterrupt. */
  5. __sighandler_t
  6. __signal (int sig, __sighandler_t handler, int flags)
  7. {
  8. int ret;
  9. struct sigaction action, oaction;
  10. memset(&action, 0, sizeof(struct sigaction));
  11. action.sa_handler = handler;
  12. action.sa_flags = flags;
  13. ret = sigaction (sig, &action, &oaction);
  14. return (ret == -1) ? SIG_ERR : oaction.sa_handler;
  15. }
  16. __sighandler_t
  17. signal (int sig, __sighandler_t handler)
  18. {
  19. return __signal(sig, handler, (SA_ONESHOT | SA_NOMASK | SA_INTERRUPT) & ~SA_RESTART);
  20. }