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(())