sigaction.c 1021 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Copyright (C) 2016 Andes Technology, Inc.
  3. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  4. */
  5. #include <errno.h>
  6. #include <signal.h>
  7. #include <sys/syscall.h>
  8. #include <string.h>
  9. #include <bits/kernel_sigaction.h>
  10. #define SA_RESTORER 0x04000000
  11. extern void __default_sa_restorer(void);
  12. int __libc_sigaction(int sig, const struct sigaction *act,
  13. struct sigaction *oact)
  14. {
  15. struct sigaction kact;
  16. if (act && !(act->sa_flags & SA_RESTORER)) {
  17. memcpy(&kact, act, sizeof(kact));
  18. kact.sa_restorer = __default_sa_restorer;
  19. kact.sa_flags |= SA_RESTORER;
  20. act = &kact;
  21. }
  22. /* NB: kernel (as of 2.6.25) will return EINVAL
  23. * if sizeof(act->sa_mask) does not match kernel's sizeof(sigset_t) */
  24. return __syscall_rt_sigaction(sig, act, oact, sizeof(act->sa_mask));
  25. }
  26. #ifndef LIBC_SIGACTION
  27. # ifndef __UCLIBC_HAS_THREADS__
  28. strong_alias(__libc_sigaction,sigaction)
  29. libc_hidden_def(sigaction)
  30. # else
  31. weak_alias(__libc_sigaction,sigaction)
  32. libc_hidden_weak(sigaction)
  33. # endif
  34. #endif