summaryrefslogtreecommitdiffstats
path: root/libc/unistd/usleep.c
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2010-01-07 15:54:35 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-01-07 15:54:35 -0800
commit0b5db51ea6d9c0b877d2ce26440d963760c38dfe (patch)
tree265b0d9536ad4c39e64cd3b550c5ff9eb20b073f /libc/unistd/usleep.c
parentee84231886c2122ea4ac62fff5334e16a26b2ab6 (diff)
parent99d7907611725e23b6fad3ae7acff4926504e687 (diff)
downloadbionic-0b5db51ea6d9c0b877d2ce26440d963760c38dfe.zip
bionic-0b5db51ea6d9c0b877d2ce26440d963760c38dfe.tar.gz
bionic-0b5db51ea6d9c0b877d2ce26440d963760c38dfe.tar.bz2
Merge "Fix usleep(3) return type to be POSIX-compliant."
Diffstat (limited to 'libc/unistd/usleep.c')
-rw-r--r--libc/unistd/usleep.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/libc/unistd/usleep.c b/libc/unistd/usleep.c
index 75458b1..19e8ee8 100644
--- a/libc/unistd/usleep.c
+++ b/libc/unistd/usleep.c
@@ -28,7 +28,7 @@
#include <time.h>
#include <errno.h>
-void usleep(unsigned long usec)
+int usleep(unsigned long usec)
{
struct timespec ts;
@@ -43,10 +43,13 @@ void usleep(unsigned long usec)
for (;;)
{
- if ( nanosleep( &ts, &ts ) >= 0 )
- break;
+ if ( nanosleep( &ts, &ts ) == 0 )
+ return 0;
+ // We try again if the nanosleep failure is EINTR.
+ // The other possible failures are EINVAL (which we should pass through),
+ // and ENOSYS, which doesn't happen.
if ( errno != EINTR )
- break;
+ return -1;
}
}