X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=directfifowatcher.ml;h=f3e334db3366133d1285e47ec7ec4f62c582c796;hb=29c254469667d325b86ec3fa438581ab34f3244d;hp=7fa91929917835b3b6d436109fe3d7c80ab1e14d;hpb=16c8bb31dd971b7fab00dbb17a75bb08cee463c6;p=vsys.git diff --git a/directfifowatcher.ml b/directfifowatcher.ml index 7fa9192..f3e334d 100644 --- a/directfifowatcher.ml +++ b/directfifowatcher.ml @@ -21,9 +21,8 @@ open Splice let close_if_open fd = (try (ignore(close fd);) with _ -> ()) - let direct_fifo_table: (string,(string*string*string*Unix.file_descr) option) Hashtbl.t = Hashtbl.create 1024 -let pidmap: (int,string) Hashtbl.t = Hashtbl.create 1024 +let pidmap: (int,string*Unix.file_descr) Hashtbl.t = Hashtbl.create 1024 let rec list_check lst elt = match lst with @@ -77,7 +76,7 @@ let connect_file fqp_in = clear_nonblock fifo_fdin; let pid=try Some(create_process execpath [|execpath;slice_name|] fifo_fdin fifo_fdout fifo_fdout) with e -> None in match pid with - | Some(pid) ->Hashtbl.add pidmap pid fqp_in + | Some(pid) ->Hashtbl.add pidmap pid (fqp_in,fifo_fdout) | None ->fprintf logfd "Error executing service: %s\n" execpath;flush logfd;reopenentry fqp_in ); ignore(sigprocmask SIG_UNBLOCK [Sys.sigchld]); @@ -121,9 +120,12 @@ let closeentry fqp = let sigchld_handle s = let pid,_=Unix.waitpid [Unix.WNOHANG] 0 in try - let fqp_in = Hashtbl.find pidmap pid in - printf "Reopening fifo\n";flush Pervasives.stdout; - reopenentry fqp_in + let fqp_in,fd_out = Hashtbl.find pidmap pid in + begin + reopenentry fqp_in; + if (fd_out <> stdout) then close_if_open fd_out + end + with _ -> () let rec add_dir_watch fqp =