Avoid deadlock of ruby open4
If we keep reading both stdout and stderr using ruby and open4, there
might be change that deadlock happen when data reach the buffer limit.
What should be the code to avoid the situation?
status = Open4::popen2e(command) do | pid, stderr|
logger.info("Executing: #{command}")
errors = stderr.readlines
unless errors.empty?
logger.error( "Error: stderr: #{errors}")
end
end
No comments:
Post a Comment