libc: return on nanosleep with zero timeout

In case the calculated timeout value is zero return directly and do
not call Libc::suspend as it will suspend us indefinitely.

Fixes #2636.
This commit is contained in:
Josef Söntgen 2018-01-08 14:50:56 +01:00 committed by Christian Helmuth
parent 2b711f59ed
commit a867c29633

View File

@ -21,6 +21,8 @@ int _nanosleep(const struct timespec *req, struct timespec *rem)
{
unsigned long sleep_ms = req->tv_sec*1000 + req->tv_nsec/1000000;
if (!sleep_ms) return 0;
struct Check : Libc::Suspend_functor { bool suspend() override { return true; } } check;
do { sleep_ms = Libc::suspend(check, sleep_ms); } while (sleep_ms);