Make clear_exited_pid work on running processes

This commit is contained in:
pjht 2024-11-08 14:13:13 -06:00
parent 4548d9540e
commit 50e7b7236e
Signed by: pjht
GPG Key ID: CA239FC6934E6F3A

View File

@ -354,10 +354,13 @@ impl Tasking {
pub fn clear_exited_pid(&self, pid: usize) -> Result<(), ()> { pub fn clear_exited_pid(&self, pid: usize) -> Result<(), ()> {
if self.current_pid() == Some(pid) {
return Err(());
}
let mut processes = self.processes.write(); let mut processes = self.processes.write();
let process = processes.get(pid).ok_or(())?; let process = processes.get(pid).ok_or(())?;
if *process.sleeping.read() != Some(SleepReason::Exited) { if process.sleeping.read().is_none() {
return Err(()); self.ready_to_run.lock().retain(|e| *e != pid);
} }
self.freeable_kstacks.lock().push(processes.remove(pid).kernel_stack); self.freeable_kstacks.lock().push(processes.remove(pid).kernel_stack);
Ok(()) Ok(())