sigaction.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (C) 2004-2007 Atmel Corporation
  3. *
  4. * This file is subject to the terms and conditions of the GNU Lesser General
  5. * Public License. See the file "COPYING.LIB" in the main directory of this
  6. * archive for more details.
  7. */
  8. #include <errno.h>
  9. #include <signal.h>
  10. #include <string.h>
  11. #include <sys/syscall.h>
  12. #include <bits/kernel_sigaction.h>
  13. #define SA_RESTORER 0x04000000
  14. extern void __default_rt_sa_restorer(void);
  15. /*
  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. */
  19. int __libc_sigaction(int sig, const struct sigaction *act,
  20. struct sigaction *oact)
  21. {
  22. struct sigaction kact;
  23. if (act && !(act->sa_flags & SA_RESTORER)) {
  24. memcpy(&kact, act, sizeof(kact));
  25. kact.sa_restorer = __default_rt_sa_restorer;
  26. kact.sa_flags |= SA_RESTORER;
  27. act = &kact;
  28. }
  29. /* NB: kernel (as of 2.6.25) will return EINVAL
  30. * if sizeof(act->sa_mask) does not match kernel's sizeof(sigset_t) */
  31. return __syscall_rt_sigaction(sig, act, oact, sizeof(act->sa_mask));
  32. }
  33. #ifndef LIBC_SIGACTION
  34. # ifndef __UCLIBC_HAS_THREADS__
  35. strong_alias(__libc_sigaction,sigaction)
  36. libc_hidden_def(sigaction)
  37. # else
  38. weak_alias(__libc_sigaction,sigaction)
  39. libc_hidden_weak(sigaction)
  40. # endif
  41. #endif