I am working on a ruby ββscript that ultimately runs a system process that takes quite a while. I need to read this process from stderr and respond to it depending on what is output.
I am currently doing this as:
Open3.popen3(cmd_to_run) do |stdin, stdout, stderr, waitthread| stderr.each_line do |line| # look out for specific lines and react to them accordingly end end
But I also saw implementations to achieve something similar, but I am doing this with kernel # select :
Open3.popen3(cmd_to_run) do |stdin, stdout, stderr, waitthread| io = select([stderr], nil, nil, 30) if io.nil? log("Command timed out during Kernel#select") return end io[0][0].each_line do |line| # look out for specific lines and react to them accordingly end end
I read the pickaxe description, which makes a choice, but am confused by why I should (if I should) use it? The first method works the same way.
Brian source share