From 6e1343d5ccbaf2a30add5105e0c4e15da22a2910 Mon Sep 17 00:00:00 2001 From: Matheus Date: Thu, 12 Sep 2024 20:19:30 -0300 Subject: [PATCH] sleep: fix errno and check if remaining is null --- kernel-src/sys/syscalls/sleep.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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);