sleep: fix errno and check if remaining is null

This commit is contained in:
Matheus
2024-09-12 20:19:30 -03:00
parent 62b28a8e2a
commit 6e1343d5cc
+2 -2
View File
@@ -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);