pause.c 866 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. int
  19. __libc_pause (void)
  20. {
  21. sigset_t set;
  22. __sigemptyset (&set);
  23. sigprocmask (SIG_BLOCK, NULL, &set);
  24. /* pause is a cancellation point, but so is sigsuspend.
  25. So no need for anything special here. */
  26. return sigsuspend (&set);
  27. }
  28. weak_alias (__libc_pause, pause)
  29. #ifdef __UCLIBC_HAS_THREADS_NATIVE__
  30. LIBC_CANCEL_HANDLED (); /* sigsuspend handles our cancellation. */
  31. #endif