Skip to content

Commit

Permalink
Fix child_alive
Browse files Browse the repository at this point in the history
waitpid only works on subprocesses.
  • Loading branch information
pitag-ha committed Mar 1, 2024
1 parent 86fe26a commit 8143bb4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bin/play.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ let handle_control_c () =

let play ~tracing midi_out channel scale argv =
Midi.channel := channel - 1;
let dir, pid =
let dir, pid, child_alive =
match argv with
| first_arg :: args ->
let dir, file =
My_fpath.(split_base @@ handle_result @@ of_string first_arg)
in
if String.equal (My_fpath.get_ext file) ".event" then
let pid = int_of_string @@ My_fpath.(to_string @@ rem_ext file) in
(My_fpath.to_string dir, pid)
(My_fpath.to_string dir, pid, fun () -> true)
else
let args = Array.of_list args in
let pid =
Unix.create_process_env first_arg args
[| "OCAML_RUNTIME_EVENTS_START=1" |]
Unix.stdin Unix.stdout Unix.stderr
in
(".", pid)
(".", pid, Util.child_alive pid)
| _ ->
failwith
"cardio-crumble expects a positional argument. It can be either the \
Expand All @@ -35,7 +35,7 @@ let play ~tracing midi_out channel scale argv =
let device = Midi.Device.create_output midi_out in
let _ = handle_control_c () in
Unix.sleepf 0.1;
tracing device (Util.child_alive pid)
tracing device child_alive
(Some (dir, pid))
(Midi.Scale.get ~base_note:48 scale);
print_endline "got to the end";
Expand Down

0 comments on commit 8143bb4

Please sign in to comment.