Fix #174: Use nanosleep() instead of usleep()

usleep() cannot sleep for more than 1000000 microseconds on certain
platforms. nanosleep() does not have this limitation.
This commit is contained in:
Jon Lund Steffensen
2015-02-22 11:51:22 -05:00
parent 7818b4aa74
commit 8b0a67a253
+5 -1
View File
@@ -24,6 +24,7 @@
# if _POSIX_TIMERS > 0
# include <time.h>
# else
# include <time.h>
# include <sys/time.h>
# endif
#else
@@ -74,7 +75,10 @@ void
systemtime_msleep(unsigned int msecs)
{
#ifndef _WIN32
usleep(msecs*1000);
struct timespec sleep;
sleep.tv_sec = msecs / 1000;
sleep.tv_nsec = (msecs % 1000)*1000000;
nanosleep(&sleep, NULL);
#else
Sleep(msecs);
#endif