tori-rs/ocaml/lib/system/process/fork.ml
2025-04-19 19:09:16 -03:00

12 lines
444 B
OCaml

let run (command : Command.command) : Command.command =
match Unix.fork () with
| 0 -> Unix.execvp command.name (Array.of_list command.arguments)
| pid -> (
let _, status = Unix.waitpid [] pid in
match status with
| WSTOPPED n | WSIGNALED n | WEXITED n ->
{ command with status = Exit n }
)
let run_many (commands : Command.command list) : Command.command list =
List.map run commands