signal.c 514 B

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