From c3f90e26a5160c3fe287c4283e7a2bc1ff54b1a9 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 6 Jun 2003 17:34:54 +0000 Subject: Update. * sysdeps/unix/sysv/linux/sleep.c (__sleep): Use nanosleep syscall directly to avoid cancellation in the regular nanosleep implementation. --- sysdeps/unix/sysv/linux/sleep.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'sysdeps') diff --git a/sysdeps/unix/sysv/linux/sleep.c b/sysdeps/unix/sysv/linux/sleep.c index 0cf6be285d..38c197358f 100644 --- a/sysdeps/unix/sysv/linux/sleep.c +++ b/sysdeps/unix/sysv/linux/sleep.c @@ -1,5 +1,5 @@ /* Implementation of the POSIX sleep function using nanosleep. - Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 1999, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1996. @@ -24,8 +24,12 @@ #include /* We are going to use the `nanosleep' syscall of the kernel. But the - kernel does not implement the sstupid SysV SIGCHLD vs. SIG_IGN - behaviour for this syscall. Therefore we have to emulate it here. */ + kernel does not implement the stupid SysV SIGCHLD vs. SIG_IGN + behaviour for this syscall. Therefore we have to emulate it here. + + Also note that we use the syscall directly instead of using the + __nanosleep function. The reason is that nanosleep() is a cancellation + point while sleep() isn't. */ unsigned int __sleep (unsigned int seconds) { @@ -67,7 +71,7 @@ __sleep (unsigned int seconds) if (oact.sa_handler == SIG_IGN) { /* We should leave SIGCHLD blocked. */ - result = __nanosleep (&ts, &ts); + result = INLINE_SYSCALL (nanosleep, 2, &ts, &ts); saved_errno = errno; /* Restore the original signal mask. */ @@ -78,11 +82,11 @@ __sleep (unsigned int seconds) { /* We should unblock SIGCHLD. Restore the original signal mask. */ (void) __sigprocmask (SIG_SETMASK, &oset, (sigset_t *) NULL); - result = __nanosleep (&ts, &ts); + result = INLINE_SYSCALL (nanosleep, 2, &ts, &ts); } } else - result = __nanosleep (&ts, &ts); + result = INLINE_SYSCALL (nanosleep, 2, &ts, &ts); if (result != 0) /* Round remaining time. */ -- cgit v1.2.3