sigprocmask.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* Copyright (C) 1997-2019 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <http://www.gnu.org/licenses/>. */
  14. #include <errno.h>
  15. #include <signal.h>
  16. #include <string.h> /* Needed for string function builtin redirection. */
  17. #include <unistd.h>
  18. #include <sysdep.h>
  19. #include <sys/syscall.h>
  20. #include <nptl/pthreadP.h> /* SIGCANCEL, SIGSETXID */
  21. /* Get and/or change the set of blocked signals. */
  22. int
  23. __sigprocmask (int how, const sigset_t *set, sigset_t *oset)
  24. {
  25. sigset_t local_newmask;
  26. /* The only thing we have to make sure here is that SIGCANCEL and
  27. SIGSETXID are not blocked. */
  28. if (set != NULL
  29. && (__builtin_expect (__sigismember (set, SIGCANCEL), 0)
  30. || __builtin_expect (__sigismember (set, SIGSETXID), 0)))
  31. {
  32. local_newmask = *set;
  33. __sigdelset (&local_newmask, SIGCANCEL);
  34. __sigdelset (&local_newmask, SIGSETXID);
  35. set = &local_newmask;
  36. }
  37. return INLINE_SYSCALL (rt_sigprocmask, 4, how, set, oset, _NSIG / 8);
  38. }
  39. libc_hidden_def (__sigprocmask)
  40. weak_alias (__sigprocmask, sigprocmask)