usleep

Peter Jeremy peterjeremy at optushome.com.au
Fri Feb 22 18:08:26 UTC 2008


On Fri, Feb 22, 2008 at 05:14:47PM +0200, Andrew Pogrebennyk wrote:
>Additionally, this C routine is considered obsolete

Can you provide a reference for this please.

> (unlike shell command by the same name).

I've never seen a shell function called usleep.  Which shell are you using?

> The interaction of this function with SIGALRM
>and other timer functions such as sleep(), alarm(), setitimer(), and
>nanosleep() is unspecified.

Possibly on some OSs but not on FreeBSD.

> Additionally, its use in multi-threaded
>programs can lead to somewhat surprising results.

Such as?  If you are talking about having the process suspended
instead of the thread then this is dependent on the threading library
and the thread attributes and is no more or less surprising than any
other similar function.

> Use nanosleep(2) or setitimer(2) instead.

If you bothered to read what Sharad had said, the man page or the source,
you would find that usleep(3) _is_ implemented using nanosleep(2) so there
is no point in using nanosleep() instead of usleep().

-- 
Peter Jeremy
Please excuse any delays as the result of my ISP's inability to implement
an MTA that is either RFC2821-compliant or matches their claimed behaviour.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20080222/3f620504/attachment.pgp


More information about the freebsd-hackers mailing list