X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=directfifowatcher.ml;h=60c098710c48ca644ac031731fe675a2bd0c9deb;hb=35a64cada2c6a40baa730404d298a5032a28c201;hp=397229275b913adb6882bbf8080c12356e60c43c;hpb=46e48c60e9d524bf71631561e193c443613a2bb5;p=vsys.git diff --git a/directfifowatcher.ml b/directfifowatcher.ml index 3972292..60c0987 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 @@ -76,9 +75,10 @@ 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 - if (fifo_fdout <> stdout) then close_if_open fifo_fdout; match pid with - | Some(pid) ->Hashtbl.add pidmap pid fqp_in + | Some(pid) -> + if (fifo_fdout <> stdout) then close_if_open fifo_fdout; + 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]); @@ -122,8 +122,11 @@ let closeentry fqp = let sigchld_handle s = let pid,_=Unix.waitpid [Unix.WNOHANG] 0 in try - let fqp_in = Hashtbl.find pidmap pid in + let fqp_in,fd_out = Hashtbl.find pidmap pid in + begin reopenentry fqp_in + end + with _ -> () let rec add_dir_watch fqp =