From ba613ce628dc809b5f5c7abe05174403e3f7d150 Mon Sep 17 00:00:00 2001 From: Ron Williams Date: Wed, 26 Feb 2025 21:00:23 +0000 Subject: [PATCH] Nanosleep: Return time remaining after interrupt --- src/syscall/time.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/syscall/time.rs b/src/syscall/time.rs index 3cb871d2b5..ddf6b2385a 100644 --- a/src/syscall/time.rs +++ b/src/syscall/time.rs @@ -48,9 +48,7 @@ pub fn nanosleep(req_buf: UserSliceRo, rem_buf_opt: Option) -> Resu // reason? context::switch(); - if current_context.write().wake.take().is_some() { - return Err(Error::new(EINTR)); - } + let was_interrupted = current_context.write().wake.take().is_some(); if let Some(rem_buf) = rem_buf_opt { let current = time::monotonic(); @@ -69,7 +67,11 @@ pub fn nanosleep(req_buf: UserSliceRo, rem_buf_opt: Option) -> Resu })?; } - Ok(()) + if was_interrupted { + Err(Error::new(EINTR)) + } else { + Ok(()) + } } pub fn sched_yield() -> Result<()> {