Don't violate POSIX by ensuring that the argument to usleep(3) is less than 1000000

fixes #12391

Signed-off-by: Gunnar Beutner <gunnar.beutner@netways.de>
This commit is contained in:
Timo Buhrmester 2016-08-10 11:51:13 +02:00 committed by Gunnar Beutner
parent 37bd5ad800
commit 148b4da285
1 changed files with 5 additions and 1 deletions

View File

@ -421,7 +421,11 @@ pid_t Utility::GetPid(void)
void Utility::Sleep(double timeout)
{
#ifndef _WIN32
usleep(timeout * 1000 * 1000);
unsigned long micros = timeout * 1000000u;
if (timeout >= 1.0)
sleep((unsigned)timeout);
usleep(micros % 1000000u);
#else /* _WIN32 */
::Sleep(timeout * 1000);
#endif /* _WIN32 */