diff --git a/infer/src/base/ProcessPool.ml b/infer/src/base/ProcessPool.ml index 6262198d2..336c8cd34 100644 --- a/infer/src/base/ProcessPool.ml +++ b/infer/src/base/ProcessPool.ml @@ -189,11 +189,15 @@ let killall pool ~slot status = let has_dead_child pool = + let open Option.Monad_infix in Unix.wait_nohang `Any - |> Option.map ~f:(fun (dead_pid, status) -> - ( Array.find_mapi_exn pool.slots ~f:(fun slot {pid} -> - if Pid.equal pid dead_pid then Some slot else None ) - , status ) ) + >>= fun (dead_pid, status) -> + (* Some joker can [exec] an infer binary from a process that already has children. When some of + these pre-existing children die they'll get detected here but won't appear in our list of + workers. Just return [None] in that case. *) + Array.find_mapi pool.slots ~f:(fun slot {pid} -> + if Pid.equal pid dead_pid then Some slot else None ) + >>| fun slot -> (slot, status) let child_is_idle = function Idle -> true | _ -> false