[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#350055: glibc-doc: nanosleep documentation misleading about second (output) argument behavior



Package: glibc-doc
Version: 2.3.5-8
Severity: normal


The nanosleep info documentation seems to be saying that the second
argument (struct timespec *REMAINING in that reference) is filled in
with a timespec value of 0 even if the function was not interupted by
a signal:

 -- Function: int nanosleep (const struct timespec *REQUESTED_TIME,
          struct timespec *REMAINING)
     If resolution to seconds is not enough the `nanosleep' function
          can
     be used.  As the name suggests the sleep interval can be
          specified
     in nanoseconds.  The actual elapsed time of the sleep interval
     might be longer since the system rounds the elapsed time you
     request up to the next integer multiple of the actual resolution
     the system can deliver.

     *`requested_time' is the elapsed time of the interval you want to
     sleep.

     The function returns as *`remaining' the elapsed time left in the
     interval for which you requested to sleep.  If the interval
     completed without getting interrupted by a signal, this is zero.

In reality this is not the case.  `remaining' is only filled in if
nanosleep returned -1.  This implemented behavior is consistent with
the documentation visible in 'man nanosleep' and these other
references:

http://www.opengroup.org/onlinepubs/007908799/xsh/nanosleep.html
http://www.die.net/doc/linux/man/man2/nanosleep.2.html
http://www.mkssoftware.com/docs/man3/nanosleep.3.asp
http://docs.hp.com/en/B9106-90009/nanosleep.2.html

Note that since `remaining' is probably untouched if 0 is returned,
the behavior the info page is describing could be achieved by setting
`remaining' to {0, 0} before the nanosleep call.  However, the info
documentation doesn't say anywhere that this should be done.


-- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.12-1-k7
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

-- no debconf information



Reply to: