pause.c 978 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. #include <sys/syscall.h>
  10. #include <unistd.h>
  11. #include <cancel.h>
  12. #ifdef __NR_pause
  13. /* even if it is not obvious, glibc uses the pause syscall, see syscalls.list */
  14. # define __NR___pause_nocancel __NR_pause
  15. static _syscall0(int, __NC(pause))
  16. CANCELLABLE_SYSCALL(int, pause, (void), ())
  17. #else
  18. # define __need_NULL
  19. # include <stddef.h>
  20. # include <signal.h>
  21. int
  22. # ifdef __UCLIBC_HAS_LINUXTHREADS__
  23. weak_function
  24. # endif
  25. __NC(pause)(void)
  26. {
  27. sigset_t set;
  28. /*__sigemptyset (&set); - why? */
  29. sigprocmask (SIG_BLOCK, NULL, &set);
  30. /* pause is a cancellation point, but so is sigsuspend.
  31. So no need for anything special here. */
  32. return sigsuspend(&set);
  33. }
  34. CANCELLABLE_SYSCALL(int, pause, (void), ())
  35. LIBC_CANCEL_HANDLED (); /* sigsuspend handles our cancellation. */
  36. #endif