- Hashtbl.add pidmap pid (Infd(myinfd),Outfd(myoutfd),evfd);
- Hashtbl.add open_fds evfd (Process(out_channel_of_descr myoutfd));
- Hashtbl.add open_fds myinfd (Fifo(out_channel_of_descr outfd));
- Fdwatcher.add_fd (None,myinfd) (None,myinfd) receive_process_event;
- (Process(out_channel_of_descr myoutfd))
+ match rpid with
+ | None-> BrokenPipe
+ | Some(pid)->
+ (* Register fds associated with pid so that they can be cleaned up
+ * when it dies *)
+ Hashtbl.add pidmap pid [Infd(script_infd);Outfd(script_outfd);Eventfd(evfd)];
+
+ (* Connect pipe to running script *)
+ Hashtbl.add open_fds evfd (Process(out_channel_of_descr script_outfd));
+
+ (* Connect the running script to the pipe *)
+ Hashtbl.add open_fds script_infd (Fifo(out_channel_of_descr outfd));
+
+ (* Activate running script *)
+ Fdwatcher.add_fd (None,script_infd) (None,script_infd) receive_process_event;
+
+ (Process(out_channel_of_descr script_outfd))