diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-01-11 14:42:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-11 14:42:10 +0100 |
commit | f414a323b168896a7350638d621636cd89b38c42 (patch) | |
tree | b05f45155405ba259d6ec1a726a63bcd95c1fd64 /drivers/unix | |
parent | 51992250e67d0fea1087ee3d9973f0b825349884 (diff) | |
parent | 1107c7f327f6d14010b4bd45b25e3c47f89b9948 (diff) |
Merge pull request #42740 from lolleko/fix-nanosleep-usage
Fix nanosleep usage
Diffstat (limited to 'drivers/unix')
-rw-r--r-- | drivers/unix/os_unix.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index d9c2a754d6..dfa7ba895d 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -234,8 +234,11 @@ OS::TimeZoneInfo OS_Unix::get_time_zone_info() const { } void OS_Unix::delay_usec(uint32_t p_usec) const { - struct timespec rem = { static_cast<time_t>(p_usec / 1000000), (static_cast<long>(p_usec) % 1000000) * 1000 }; - while (nanosleep(&rem, &rem) == EINTR) { + struct timespec requested = { static_cast<time_t>(p_usec / 1000000), (static_cast<long>(p_usec) % 1000000) * 1000 }; + struct timespec remaining; + while (nanosleep(&requested, &remaining) == -1 && errno == EINTR) { + requested.tv_sec = remaining.tv_sec; + requested.tv_nsec = remaining.tv_nsec; } } |