This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: A patch for nanosleep


hjl@lucon.org (H.J. Lu) writes:

> Here is an optimized nanosleep.c for glibc 2.

I looked though the sleep, nanosleep, alarm, and SIGCHLD documentation
in POSIX and Unix98 and haven't found a reason why there must be any
change.

It is said that SIGCHLD has to be treated a bit special by the signal
code as the SIG_IGN and SIG_DFL actions are so stupid.  So be it.

But where does this effect this case?  When I write a simple program

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include <unistd.h>
#include <sys/types.h>

int
main()
{
  pid_t p = fork();
  if (p == 0)
    {
      sleep (1);
      exit (0);
    }

  sleep (5);

  return 0;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I do see something weird only when using strace to run the program.
If I run it normally it just fine stops after five seconds.  When
using strace it returns as soon as it gets the SIGCHLD signal, but is
this a problem with the libc of strace?


Anyhow, even if somebody can tell me that there is a problem with
sleep (maybe for historical reasons) I'm not convinced there is a
problem with nanosleep.  It seems to work as expected.  If the sleep()
behaviour must change we must not change nanosleep.  HJ patch could
then be applied to sleep.


So please, enlighten me on this.  Thanks,

-- 
---------------.      drepper at gnu.org  ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Cygnus Solutions `--' drepper at cygnus.com   `------------------------


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]