1 (** Fdwatcher - The main event loop. Agnostic to the type of file descriptors
8 let cbtable = Hashtbl.create 1024
10 (* The in descriptor is always open. Thanks to the broken semantics of
11 * fifo outputs, the out descriptor must be opened a nouveau whenever we
12 * want to send out data, and so we keep the associated filename as well.
13 * Same with input fifos. Yipee.*)
14 let add_fd (evpair:fname_and_fd) (fd_other:fname_and_fd) (callback:fname_and_fd->fname_and_fd->unit) =
15 let (fname,fd) = evpair in
16 fdset := (fd::!fdset);
17 Hashtbl.replace cbtable fd (callback,(evpair,fd_other))
20 fdset:=List.filter (fun l->l<>fd) !fdset;
21 flush Pervasives.stdout
26 let (fds,_,_) = try Unix.select !fdset [] [] (-1.)
31 let (func,(evd,fd_other)) = Hashtbl.find cbtable elt in
32 func evd fd_other) fds