pause.c 953 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * pause() for uClibc
  3. *
  4. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  5. *
  6. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  7. */
  8. #include <sys/syscall.h>
  9. #include <unistd.h>
  10. #include <cancel.h>
  11. #ifdef __NR_pause
  12. /* even if it is not obvious, glibc uses the pause syscall, see syscalls.list */
  13. # define __NR___pause_nocancel __NR_pause
  14. static _syscall0(int, __NC(pause))
  15. CANCELLABLE_SYSCALL(int, pause, (void), ())
  16. #else
  17. # define __need_NULL
  18. # include <stddef.h>
  19. # include <signal.h>
  20. int
  21. # ifdef __UCLIBC_HAS_LINUXTHREADS__
  22. weak_function
  23. # endif
  24. __NC(pause)(void)
  25. {
  26. sigset_t set;
  27. /*__sigemptyset (&set); - why? */
  28. sigprocmask (SIG_BLOCK, NULL, &set);
  29. /* pause is a cancellation point, but so is sigsuspend.
  30. So no need for anything special here. */
  31. return sigsuspend(&set);
  32. }
  33. CANCELLABLE_SYSCALL(int, pause, (void), ())
  34. LIBC_CANCEL_HANDLED (); /* sigsuspend handles our cancellation. */
  35. #endif