Merge pull request #43 from wnsntgs/Kernel/Sched/NanosleepTimerFix

Fix timer cleanup in interrupted nanosleep
This commit is contained in:
Matheus
2026-09-23 15:09:28 -03:00
committed by GitHub
+6 -4
View File
@@ -32,11 +32,13 @@ syscallret_t syscall_nanosleep(context_t *, timespec_t *utime, timespec_t *remai
ret.errno = sched_yield() == SCHED_WAKEUP_REASON_INTERRUPTED ? EINTR : 0; ret.errno = sched_yield() == SCHED_WAKEUP_REASON_INTERRUPTED ? EINTR : 0;
if (ret.errno && remaining) { if (ret.errno) {
uintmax_t remainingus = timer_remove(current_cpu()->timer, &sleepentry); uintmax_t remainingus = timer_remove(current_cpu()->timer, &sleepentry);
time.ns = (remainingus % 1000000) * 1000; if (remaining) {
time.s = (remainingus / 1000000); time.ns = (remainingus % 1000000) * 1000;
ret.errno = usercopy_touser(remaining, &time, sizeof(timespec_t)) ? EFAULT : EINTR; time.s = (remainingus / 1000000);
ret.errno = usercopy_touser(remaining, &time, sizeof(timespec_t)) ? EFAULT : EINTR;
}
} }
sched_target_cpu(NULL); sched_target_cpu(NULL);