- | Process(out_channel) ->
- let cont = ref true in
- while (!cont) do
- try
- fprintf logfd "Reading...\n";flush logfd;
- let curline = input_line inchan_fd in
- fprintf out_channel "%s\n" curline;flush out_channel
- with
- |End_of_file->
- (
- match (evfname,fname_other) with
- | Some(str1),Some(str2)->
- fprintf logfd "Reopening entry\n";flush logfd;
- reopenentry_int evfd str1 str2
- | Some(str1),None ->
- fprintf logfd "Bug, nameless pipe\n";flush logfd;raise Bug
- | None,_ ->
- fprintf logfd "Race condition -> user deleted file before closing it. Clever ploy, but won't work.\n";
- flush logfd
- );
- cont:=false
- |Sys_blocked_io ->fprintf logfd "Sysblockedio\n";flush logfd;
- cont:=false
- | Unix_error(_,s1,s2) -> fprintf logfd "Unix error %s - %s\n" s1 s2;flush logfd;cont:=false
- (*| _ ->fprintf logfd "Bug: unhandled exception\n";flush
- * logfd;raise Bug*)
- done;
- ignore(sigprocmask SIG_UNBLOCK [Sys.sigchld])
+ | Process(fifo_outfd) ->
+ begin
+ try
+ let transferred = ref 4096 in
+ while (!transferred == 4096) do
+ begin
+ transferred:=tee evfd fifo_outfd 4096;
+ printf "Transferred: %d\n" !transferred;flush Pervasives.stdout
+ end
+ done;
+ with Failure(str) ->
+ begin
+ logprint "Error connecting user to service: %s\n" str
+ end;
+ ignore(sigprocmask SIG_UNBLOCK [Sys.sigchld]);
+ printf "Out of the loop\n";flush Pervasives.stdout
+
+ end