From: Timo Buhrmester Date: Wed, 10 Aug 2016 09:51:13 +0000 (+0200) Subject: Don't violate POSIX by ensuring that the argument to usleep(3) is less than 1000000 X-Git-Tag: v2.5.0~99 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=148b4da285859cb33fea42b5152ed0cbce6d6650;p=icinga2 Don't violate POSIX by ensuring that the argument to usleep(3) is less than 1000000 fixes #12391 Signed-off-by: Gunnar Beutner --- 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 */