From 914e96b33716dc10cab9ebf6e93a90f907015eac Mon Sep 17 00:00:00 2001 From: EnderIce2 Date: Sun, 3 Mar 2024 23:58:12 +0200 Subject: [PATCH] Handle signal interruptions during sleep --- syscalls/linux.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/syscalls/linux.cpp b/syscalls/linux.cpp index 3959a92..1733d63 100644 --- a/syscalls/linux.cpp +++ b/syscalls/linux.cpp @@ -650,9 +650,13 @@ static int linux_nanosleep(SysFrm *, while (time < sleepTime) { + if (pcb->Signals->HasPendingSignal()) + { + debug("sleep interrupted by signal"); + return -EINTR; + } + pcb->GetContext()->Yield(); - /* TODO: sleep should be interrupted by - the signal and return errno EINTR */ time = TimeManager->GetCounter(); } debug("time= %ld", time);