sigpause.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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, write to the Free
  14. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA. */
  16. #define sigdelset __sigdelset_internal
  17. #include <errno.h>
  18. #include <signal.h>
  19. #include <stddef.h> /* For NULL. */
  20. #include "sigset-cvt-mask.h"
  21. /* Set the mask of blocked signals to MASK,
  22. wait for a signal to arrive, and then restore the mask. */
  23. int __sigpause (int sig_or_mask, int is_sig)
  24. {
  25. sigset_t set;
  26. if (is_sig != 0)
  27. {
  28. /* The modern X/Open implementation is requested. */
  29. if (__sigprocmask (0, NULL, &set) < 0
  30. /* Yes, we call `sigdelset' and not `__sigdelset'. */
  31. || sigdelset (&set, sig_or_mask) < 0)
  32. return -1;
  33. }
  34. else if (sigset_set_old_mask (&set, sig_or_mask) < 0)
  35. return -1;
  36. return sigsuspend (&set);
  37. }
  38. #undef sigpause
  39. /* We have to provide a default version of this function since the
  40. standards demand it. The version which is a bit more reasonable is
  41. the BSD version. So make this the default. */
  42. int sigpause (int mask)
  43. {
  44. return __sigpause (mask, 0);
  45. }