3

POSIX standard for usleep clearly states:

The useconds argument shall be less than one million.

Why is it so?

Are there any known operating systems/libraries that actually enforce this restriction? Man pages for Linux, macOS, FreeBSD and Solaris does not mention this limitation.

  • [The Man](https://linux.die.net/man/3/usleep) does not report that limit. Maybe old doc at that link. – LPs Dec 01 '16 at 07:03
  • 1
    BTW the linked man reports _2004 Edition_. If you click on _A newer edition of this document exists [here](http://pubs.opengroup.org/onlinepubs/9699919799/)_ the `usleep` function is not listed. – LPs Dec 01 '16 at 07:30
  • 1
    @LPs, yes, `usleep` was removed in [POSIX 1.2008](http://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xsh_chap01.html) – el.pescado - нет войне Dec 01 '16 at 07:37
  • @LP, in your lined manpage the limit is well mentioned. `EINVAL` is returned if the parameter is not less than 1 million. Also the datatype `useconds_t` is mentioned to hold integer values in range [0,1000000]. – Gerhardh Dec 01 '16 at 08:08
  • 1
    @Gerhardh: it is mentioned with note "On systems where that is considered an error", and it is not stated that it *is* an error. – el.pescado - нет войне Dec 01 '16 at 08:11
  • Interesting. My man page says: "The type useconds_t is an unsigned integer type capable of holding integers in the range [0,1000000]". It looks like if the original meaning was that it shall not be a 16bit integer. However the exact wording causes that the type is not guaranteed to hold values larger than 1000000. – Marian Dec 01 '16 at 09:37

0 Answers0