let exit system_state = if !verbose then Printf.eprintf "Exit\n%!"; let pid = system_state.current.pid in let rec waiting_parents process parents = if process.ppid == 0 then if parents = [] then raise No_waiting_parent else parents else let parent = Hashtbl.find system_state.processes process.ppid in match parent.state with | Waitpid i -> if i == pid then waiting_parents parent (parent :: parents) else waiting_parents parent parents | _ -> waiting_parents parent parents in let p = system_state.current in system_state.active_processes <- List.filter ((<>) p) system_state.active_processes; release_ptable p.preg.(pt) p.ptable_size; (* libérer la table des pages *) try let parents = waiting_parents system_state.current [] in let update parent = parent.state <- Ready; system_state.active_processes <- parent :: system_state.active_processes in List.iter update parents; remove_process p system_state.processes; schedule system_state with No_waiting_parent -> if system_state.current.ppid <> 0 then system_state.current.state <- Zombi p.preg.(a0) else remove_process p system_state.processes; schedule system_state in system_traps.(sys_Exit) <- exit;; |