[processpool] handle BoJo case

Summary:
Infer would crash when started in a context where it already had
children it didn't know about.

Reviewed By: martintrojer

Differential Revision: D19177589

fbshipit-source-id: 0c8831597
master
Jules Villard 5 years ago committed by Facebook Github Bot
parent cb9bb2a73c
commit dd2c505890

@ -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} ->
>>= 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 )
, status ) )
>>| fun slot -> (slot, status)
let child_is_idle = function Idle -> true | _ -> false

Loading…
Cancel
Save