mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-01 15:08:21 +00:00
sleep: fix errno and check if remaining is null
This commit is contained in:
@@ -30,9 +30,9 @@ syscallret_t syscall_nanosleep(context_t *, timespec_t *utime, timespec_t *remai
|
|||||||
sched_targetcpu(_cpu());
|
sched_targetcpu(_cpu());
|
||||||
timer_insert(_cpu()->timer, &sleepentry, timeout, _cpu()->thread, time.s * 1000000 + time.ns / 1000, false);
|
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);
|
uintmax_t remainingus = timer_remove(_cpu()->timer, &sleepentry);
|
||||||
time.ns = (remainingus % 1000000) * 1000;
|
time.ns = (remainingus % 1000000) * 1000;
|
||||||
time.s = (remainingus / 1000000);
|
time.s = (remainingus / 1000000);
|
||||||
|
|||||||
Reference in New Issue
Block a user