From 148b4da285859cb33fea42b5152ed0cbce6d6650 Mon Sep 17 00:00:00 2001 From: Timo Buhrmester Date: Wed, 10 Aug 2016 11:51:13 +0200 Subject: [PATCH] Don't violate POSIX by ensuring that the argument to usleep(3) is less than 1000000 fixes #12391 Signed-off-by: Gunnar Beutner --- lib/base/utility.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/base/utility.cpp b/lib/base/utility.cpp index ae2b9f6d2..9834a643e 100644 --- a/lib/base/utility.cpp +++ b/lib/base/utility.cpp @@ -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 */