let receive_process_event (idesc: fname_and_fd) (_: fname_and_fd) =
  let (_,ifd) = idesc in
  let cp = try Hashtbl.find open_fds ifd with
      Not_found->
        fprintf logfd "Fifo fd disappeared\n";flush logfd;raise Bug
  in
    match (cp) with 
      | Fifo(fifo_outfd) ->
          begin
            try
              printf "Received process event\n";flush Pervasives.stdout;
              (* transferred = 4096 => there were at least 4096 bytes in the
               * stream, so we should try again.
               * transferred < 4096 => EAGAIN => either this is all the data we
               * have (move on)
               * OR XXX the receiver is blocking (supposedly this can't happen) *)

              let transferred = ref 4096 in
                while (!transferred == 4096) do 
                  transferred:=tee ifd fifo_outfd 4096
                done;
            with 
                Failure(s)->fprintf logfd "Transfer failure: %s\n" s;flush logfd
          end
      | _ -> fprintf logfd "Bug! Process fd received in the channel handler\n";flush logfd;raise Bug