From: Ulrich Drepper Date: Thu, 14 Oct 1999 19:21:37 +0000 (+0000) Subject: (__sleep): Optimize for zero seconds. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea4f32708f2098027e832746262d24b9f5c7db08;p=thirdparty%2Fglibc.git (__sleep): Optimize for zero seconds. --- diff --git a/sysdeps/unix/sysv/linux/sleep.c b/sysdeps/unix/sysv/linux/sleep.c index 5fb11603cff..163f574da1b 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 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1996. @@ -34,6 +34,10 @@ __sleep (unsigned int seconds) struct sigaction oact; unsigned int result; + /* This is not necessary but some buggy programs depend on this. */ + if (seconds == 0) + return 0; + /* Linux will wake up the system call, nanosleep, when SIGCHLD arrives even if SIGCHLD is ignored. We have to deal with it in libc. We block SIGCHLD first. */