class SimpleProcess
Public Class Methods
new(cmd_array, data=nil)
click to toggle source
# File lib/simple_process_runner.rb, line 12 def initialize(cmd_array, data=nil) stdin, stdout, stderr, @wait_thr = Open3.popen3(*cmd_array) @stdout_thread = Thread.new do Thread.current[:result] = stdout.read stdout.close end @stderr_thread = Thread.new do Thread.current[:result] = stderr.read stderr.close end Thread.new do stdin.write data if data stdin.close end end
Public Instance Methods
wait()
click to toggle source
# File lib/simple_process_runner.rb, line 31 def wait exit_code = @wait_thr.value.exitstatus output = @stdout_thread.join[:result] error = @stderr_thread.join[:result] return exit_code, output, error end