mirror of https://github.com/Icinga/icinga2.git
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:
parent
37bd5ad800
commit
148b4da285
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue