pause.c 915 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * pause() for uClibc
  4. *
  5. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  6. *
  7. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  8. */
  9. #define __UCLIBC_HIDE_DEPRECATED__
  10. #include <sys/syscall.h>
  11. #include <unistd.h>
  12. #ifdef __UCLIBC_HAS_THREADS_NATIVE__
  13. #include <sysdep-cancel.h>
  14. #endif
  15. #include <signal.h>
  16. /* Suspend the process until a signal arrives.
  17. This always returns -1 and sets errno to EINTR. */
  18. extern __typeof(pause) __libc_pause;
  19. int
  20. __libc_pause (void)
  21. {
  22. sigset_t set;
  23. /*__sigemptyset (&set); - why? */
  24. sigprocmask (SIG_BLOCK, NULL, &set);
  25. /* pause is a cancellation point, but so is sigsuspend.
  26. So no need for anything special here. */
  27. return sigsuspend (&set);
  28. }
  29. weak_alias (__libc_pause, pause)
  30. #ifdef __UCLIBC_HAS_THREADS_NATIVE__
  31. LIBC_CANCEL_HANDLED (); /* sigsuspend handles our cancellation. */
  32. #endif