waitpid
qui retourne un code de retour plutôt qu'un
statut.
let signal_retcode = 126 (* Fils a été tué par un signal *) let return_status = function | WEXITED ret -> ret | WSIGNALED s -> eprintf "Process was killed by signal %d\n" s; flush Pervasives.stderr; signal_retcode | WSTOPPED s -> eprintf "Process was stopped by signal %d\n" s; flush Pervasives.stderr; signal_retcode;; let wait_for_son pid = let pid, status = Unix.waitpid [Unix.WUNTRACED] pid in return_status status;; |
command_wait
lance un programme et le père attend son retour.
let command_wait cmd args = match Unix.fork () with | 0 -> mon_exec cmd args | pid -> wait_for_son pid;; |