lib/knj/process_meta.rb in knjrbfw-0.0.18 vs lib/knj/process_meta.rb in knjrbfw-0.0.19
- old
+ new
@@ -29,10 +29,13 @@
pid, @stdin, @stdout, @stderr = IO.popen4("#{exec_path} --#{RUBY_VERSION[0, 3]} \"#{exec_file}\" \"#{id}\"")
else
@stdin, @stdout, @stderr = Open3.popen3(cmd)
end
+ @stdout.sync = true
+ @stdin.sync = true
+
args = {
:out => @stdin,
:in => @stdout,
:listen => true,
:debug => @args["debug"]
@@ -42,9 +45,13 @@
args[:err] = @stderr
args[:on_err] = proc{|line|
$stderr.print "stderr: #{line}"
}
end
+
+ #Wait for process to start and check that it is returning the expected output.
+ start_line = @stdout.gets
+ raise "Expected startline from process to be 'process_meta_started' but got: '#{start_line}'." if start_line != "process_meta_started\n"
@process = Knj::Process.new(args)
res = @process.send("obj" => {"type" => "process_data"})
raise "Unexpected process-data: '#{res}'." if !res.is_a?(Hash) or res["type"] != "process_data_success"
\ No newline at end of file