]> granicus.if.org Git - icinga2/commitdiff
Don't violate POSIX by ensuring that the argument to usleep(3) is less than 1000000
authorTimo Buhrmester <van.fstd@gmail.com>
Wed, 10 Aug 2016 09:51:13 +0000 (11:51 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Wed, 10 Aug 2016 10:29:52 +0000 (12:29 +0200)
fixes #12391

Signed-off-by: Gunnar Beutner <gunnar.beutner@netways.de>
lib/base/utility.cpp

index ae2b9f6d2e3c7114ba1344668e1b56fe16a97ebd..9834a643e0745797a131af7975b2952a0ff0a33e 100644 (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 */