--- a/lib/libutil/sleep.c
+++ b/lib/libutil/sleep.c
@@ -8,7 +8,7 @@
 #  include <windows.h>
 #  include <process.h>
 #else
-#  include <unistd.h>
+#  include <time.h>
 #endif
 
 
@@ -18,6 +18,7 @@ xmlrpc_millisecond_sleep(unsigned int co
 #if MSVCRT
     SleepEx(milliseconds, true);
 #else
-    usleep(milliseconds * 1000);
+    const struct timespec req = {0, milliseconds * 1000 * 1000};
+    nanosleep(&req, NULL);
 #endif
 }
