sigpause.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* Copyright (C) 1991,92,94-98,2000,2002,2003,2004
  2. Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #include <signal.h>
  16. #define __need_NULL
  17. #include <stddef.h>
  18. #include <cancel.h>
  19. #include "sigset-cvt-mask.h"
  20. /* Set the mask of blocked signals to MASK,
  21. wait for a signal to arrive, and then restore the mask. */
  22. static int __sigpause (int sig_or_mask, int is_sig)
  23. {
  24. sigset_t set;
  25. if (is_sig)
  26. {
  27. /* The modern X/Open implementation is requested. */
  28. sigprocmask (SIG_BLOCK, NULL, &set);
  29. /* Bound-check sig_or_mask, remove it from the set. */
  30. if (sigdelset (&set, sig_or_mask) < 0)
  31. return -1;
  32. }
  33. else
  34. sigset_set_old_mask (&set, sig_or_mask);
  35. /* Note the sigpause() is a cancellation point. But since we call
  36. sigsuspend() which itself is a cancellation point we do not have
  37. to do anything here. */
  38. /* uClibc note: not true on uClibc, we call the non-cancellable version */
  39. return __NC(sigsuspend)(&set);
  40. }
  41. int __bsd_sigpause(int mask);
  42. int __bsd_sigpause(int mask)
  43. {
  44. return __sigpause(mask, 0);
  45. }
  46. /* We have to provide a default version of this function since the
  47. standards demand it. The version which is a bit more reasonable is
  48. the BSD version. So make this the default. */
  49. static int __NC(sigpause)(int sig)
  50. {
  51. return __sigpause(sig, 1);
  52. }
  53. CANCELLABLE_SYSCALL(int, sigpause, (int sig), (sig))