diff options
Diffstat (limited to 'libc/sysdeps/linux/common/pause.c')
-rw-r--r-- | libc/sysdeps/linux/common/pause.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/libc/sysdeps/linux/common/pause.c b/libc/sysdeps/linux/common/pause.c index 22a039b4f..31d3563fb 100644 --- a/libc/sysdeps/linux/common/pause.c +++ b/libc/sysdeps/linux/common/pause.c @@ -10,19 +10,23 @@ #define __UCLIBC_HIDE_DEPRECATED__ #include <sys/syscall.h> #include <unistd.h> +#include <sysdep-cancel.h> -extern __typeof(pause) __libc_pause; -#ifdef __NR_pause -#define __NR___libc_pause __NR_pause -_syscall0(int, __libc_pause); -#else -#include <signal.h> -libc_hidden_proto(__sigpause) -libc_hidden_proto(sigblock) - -int __libc_pause(void) +/* Suspend the process until a signal arrives. + This always returns -1 and sets errno to EINTR. */ +int +__libc_pause (void) { - return (__sigpause(sigblock(0), 0)); + sigset_t set; + + __sigemptyset (&set); + sigprocmask (SIG_BLOCK, NULL, &set); + + /* pause is a cancellation point, but so is sigsuspend. + So no need for anything special here. */ + + return sigsuspend (&set); } -#endif -weak_alias(__libc_pause,pause) +weak_alias (__libc_pause, pause) + +LIBC_CANCEL_HANDLED (); /* sigsuspend handles our cancellation. */ |