Last active
August 29, 2015 14:17
-
-
Save mxhold/ba3549afd20db90ae2f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'open3' | |
command = '$stderr.puts("X" * 70_000); $stdout.puts("X" * 70_000)' | |
full_command = "ruby -e '#{command}'" | |
Open3.popen3(full_command) do |_in, out, err, _t| | |
out.each { |line| $stdout.puts line } | |
err.each { |line| $stderr.puts line } | |
end | |
require 'open3' | |
command = '$stderr.puts("E" * 70_000); $stdout.puts("o" * 70_000)' | |
full_command = "ruby -e '#{command}'" | |
Open3.popen3(full_command) do |_in, out, err, _t| | |
threads = [] | |
threads << Thread.new { out.each { |line| $stdout.puts line }} | |
threads << Thread.new { err.each { |line| $stderr.puts line }} | |
threads.each { |t| t.join } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment