exception No_waiting_parent;; 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); try let parents = waiting_parents system_state.current [] in let update_waiting parent = (* placer le code de retour *) parent.preg.(v1) <- p.preg.(a0); parent.state <- Ready; system_state.active_processes := parent :: !(system_state.active_processes) in List.iter update_waiting 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 <- Zombie p.preg.(a0) else remove_process p system_state.processes; schedule system_state in system_traps.(sys_Exit) <- exit;; |