File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -56,14 +56,21 @@ let exec_process (config : runtime_events_config) (argsl : string list) :
5656 raise
5757 (Fail (Printf. sprintf " executable %s not found" executable_filename))
5858 in
59- (* Poll until the child's .events ring buffer file appears.
60- The file is created by the OCaml runtime at startup, but under
61- load (e.g. parallel dune builds) process creation can be slow. *)
59+ (* Poll until the child's .events ring buffer is ready.
60+ The OCaml runtime creates the file then writes the ring buffer header,
61+ so we must wait for the file to exist AND have non-zero size.
62+ Under load (e.g. parallel dune builds) process creation can be slow. *)
6263 let ring_file = Filename. concat dir (string_of_int child_pid ^ " .events" ) in
6364 let timeout = 5.0 in
6465 let poll_interval = 0.05 in
6566 let deadline = Unix. gettimeofday () +. timeout in
66- while (not (Sys. file_exists ring_file)) && Unix. gettimeofday () < deadline do
67+ let ring_ready () =
68+ Sys. file_exists ring_file
69+ &&
70+ try (Unix. stat ring_file).Unix. st_size > 0
71+ with Unix. Unix_error _ -> false
72+ in
73+ while (not (ring_ready () )) && Unix. gettimeofday () < deadline do
6774 Unix. sleepf poll_interval
6875 done ;
6976 let cursor =
You can’t perform that action at this time.
0 commit comments