Skip to content

Commit

Permalink
Update.
Browse files Browse the repository at this point in the history
1999-10-14  Andreas Jaeger  <aj@suse.de>

	* sysdeps/unix/sysv/linux/sleep.c (__sleep): Optimize for zero
	seconds.
  • Loading branch information
Ulrich Drepper committed Oct 14, 1999
1 parent 02ab9fe commit 907ea19
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
1999-10-14 Andreas Jaeger <aj@suse.de>

* sysdeps/unix/sysv/linux/sleep.c (__sleep): Optimize for zero
seconds.

1999-10-12 Ulrich Drepper <drepper@cygnus.com>

* sysdeps/unix/sysv/linux/i386/sys/ucontext.h: Don't define
Expand Down
11 changes: 9 additions & 2 deletions sysdeps/unix/sysv/linux/sleep.c
Original file line number Diff line number Diff line change
@@ -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 <drepper@cygnus.com>, 1996.
Expand Down Expand Up @@ -31,9 +31,12 @@ __sleep (unsigned int seconds)
{
struct timespec ts = { tv_sec: (long int) seconds, tv_nsec: 0 };
sigset_t set, oset;
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. */
Expand All @@ -46,6 +49,10 @@ __sleep (unsigned int seconds)
if (!__sigismember (&oset, SIGCHLD))
{
int saved_errno;
struct sigaction oact;

if (__sigemptyset (&set) < 0 || __sigaddset (&set, SIGCHLD) < 0)
return -1;

/* We get the signal handler for SIGCHLD. */
if (__sigaction (SIGCHLD, (struct sigaction *) NULL, &oact) < 0)
Expand Down

0 comments on commit 907ea19

Please sign in to comment.