diff --git a/kernel-src/sys/syscalls/sleep.c b/kernel-src/sys/syscalls/sleep.c index cdf77458..bdbf2f92 100644 --- a/kernel-src/sys/syscalls/sleep.c +++ b/kernel-src/sys/syscalls/sleep.c @@ -30,9 +30,9 @@ syscallret_t syscall_nanosleep(context_t *, timespec_t *utime, timespec_t *remai sched_targetcpu(_cpu()); timer_insert(_cpu()->timer, &sleepentry, timeout, _cpu()->thread, time.s * 1000000 + time.ns / 1000, false); - ret.errno = sched_yield(); + ret.errno = sched_yield() == SCHED_WAKEUP_REASON_INTERRUPTED ? EINTR : 0; - if (ret.errno) { + if (ret.errno && remaining) { uintmax_t remainingus = timer_remove(_cpu()->timer, &sleepentry); time.ns = (remainingus % 1000000) * 1000; time.s = (remainingus / 1000000);