sigaction.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
  3. *
  4. * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
  5. */
  6. #include <errno.h>
  7. #include <signal.h>
  8. #include <string.h>
  9. #include <sys/syscall.h>
  10. #include <bits/kernel_sigaction.h>
  11. /*
  12. * Default sigretrun stub if user doesn't specify SA_RESTORER
  13. */
  14. extern void __default_rt_sa_restorer(void);
  15. #define SA_RESTORER 0x04000000
  16. /* If @act is not NULL, change the action for @sig to @act.
  17. If @oact is not NULL, put the old action for @sig in @oact. */
  18. int
  19. __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
  20. {
  21. struct sigaction kact;
  22. /*
  23. * SA_RESTORER is only relevant for act != NULL case
  24. * (!act means caller only wants to know @oact)
  25. */
  26. if (act && !(act->sa_flags & SA_RESTORER)) {
  27. kact.sa_restorer = __default_rt_sa_restorer;
  28. kact.sa_flags = act->sa_flags | SA_RESTORER;
  29. kact.sa_handler = act->sa_handler;
  30. kact.sa_mask = act->sa_mask;
  31. act = &kact;
  32. }
  33. return INLINE_SYSCALL(rt_sigaction, 4,
  34. sig, act, oact, sizeof(act->sa_mask));
  35. }
  36. #ifndef LIBC_SIGACTION
  37. # ifndef __UCLIBC_HAS_THREADS__
  38. strong_alias(__libc_sigaction,sigaction)
  39. libc_hidden_def(sigaction)
  40. # else
  41. weak_alias(__libc_sigaction,sigaction)
  42. libc_hidden_weak(sigaction)
  43. # endif
  44. #endif