let sigchld_handle s =
let pid,_=Unix.waitpid [Unix.WNOHANG] 0 in
try
let sfd_list = Hashtbl.find pidmap pid in
let handle_sfd sfd =
match sfd with
| Infd(fd) ->
close fd;
Fdwatcher.del_fd fd
| Outfd(fd)->
close fd
| Eventfd(fd)->
Hashtbl.remove open_fds fd (* Disconnect pipe *)
in
List.iter handle_sfd sfd_list;
Hashtbl.remove pidmap pid
with
Not_found-> (* Do nothing, probably a grandchild *)
()