let _ =
  match Unix.fork () with
  | 0 ->
      (let fd = Unix.openfile "/bin/ls" [Unix.O_RDONLY] 0o640 in
      try Fd.fexecve fd [| "/bin/ls"; "/" |] [| |] with
      Fd.Fd_error s -> print_endline s)
  | _ ->
      (let fd = Unix.openfile "/etc/passwd" [Unix.O_RDONLY] 0o640 in
      try Fd.fexecve fd [| "/etc/passwd"; |] [| |] with
      Fd.Fd_error s -> Printf.printf "fexecve failed: %s\n" s)

let run_fexecve path args env =
  let fd = Unix.openfile path [Unix.O_RDONLY] 0o640 in
  try Fd.fexecve ~fd:fd ~args:args ~env:env with
  Fd.Fd_error s -> raise (Failure s)

let _ =
  match Unix.fork () with
  | 0 -> run_fexecve "/bin/ls" [| "/bin/ls"; "/" |] [| |]
  | _ -> run_fexecve "/etc/passwd" [| "/etc/passwd" |] [| |]

Fix test by using labels. Still need to figure out why they are necessary.
Fix test by using labels. Still need to figure out why they are necessary.

