sigaction.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. extern __typeof(sigaction) __libc_sigaction;
  16. /*
  17. * If act is not NULL, change the action for sig to *act.
  18. * If oact is not NULL, put the old action for sig in *oact.
  19. */
  20. int __libc_sigaction(int sig, const struct sigaction *act,
  21. struct sigaction *oact)
  22. {
  23. struct sigaction kact;
  24. if (act && !(act->sa_flags & SA_RESTORER)) {
  25. memcpy(&kact, act, sizeof(kact));
  26. kact.sa_restorer = __default_rt_sa_restorer;
  27. kact.sa_flags |= SA_RESTORER;
  28. act = &kact;
  29. }
  30. /* NB: kernel (as of 2.6.25) will return EINVAL
  31. * if sizeof(act->sa_mask) does not match kernel's sizeof(sigset_t) */
  32. return __syscall_rt_sigaction(sig, act, oact, sizeof(act->sa_mask));
  33. }
  34. #ifndef LIBC_SIGACTION
  35. weak_alias(__libc_sigaction, sigaction)
  36. libc_hidden_weak(sigaction)
  37. #endif