From 50e7b7236e7d920d645c570b428822f6f181d9da Mon Sep 17 00:00:00 2001 From: pjht Date: Fri, 8 Nov 2024 14:13:13 -0600 Subject: [PATCH] Make clear_exited_pid work on running processes --- src/tasking.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/tasking.rs b/src/tasking.rs index 7762b28..b03aa2c 100644 --- a/src/tasking.rs +++ b/src/tasking.rs @@ -354,10 +354,13 @@ impl Tasking { pub fn clear_exited_pid(&self, pid: usize) -> Result<(), ()> { + if self.current_pid() == Some(pid) { + return Err(()); + } let mut processes = self.processes.write(); let process = processes.get(pid).ok_or(())?; - if *process.sleeping.read() != Some(SleepReason::Exited) { - return Err(()); + if process.sleeping.read().is_none() { + self.ready_to_run.lock().retain(|e| *e != pid); } self.freeable_kstacks.lock().push(processes.remove(pid).kernel_stack); Ok(())