Created
September 1, 2013 18:39
-
-
Save thinkerbot/6406361 to your computer and use it in GitHub Desktop.
Demonstrates that multiple writers to a single fifo often get inputs interleaved, regardless of sync.
This file contains hidden or 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
#!/bin/bash | |
# 8... always? | |
mkfifo fifo | |
ruby -e '100000.times {|i| puts "a"}' > fifo & | |
ruby -e '100000.times {|i| puts "b"}' > fifo & | |
ruby -e '100000.times {|i| puts "c"}' > fifo & | |
ruby -e '100000.times {|i| puts "d"}' > fifo & | |
ruby -e '100000.times {|i| puts "e"}' > fifo & | |
ruby -e '100000.times {|i| puts "f"}' > fifo & | |
ruby -e '100000.times {|i| puts "g"}' > fifo & | |
ruby -e '100000.times {|i| puts "h"}' > fifo & | |
ruby -e ' | |
counts = Hash.new(0) | |
while line = gets | |
counts[line.chomp("\n")] += 1 | |
end | |
puts counts.length | |
' < fifo | |
rm fifo |
This file contains hidden or 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
#!/bin/bash | |
# > 8 | |
mkfifo fifo | |
ruby -e '1000.times {|i| puts("a" * 1000)}' > fifo & | |
ruby -e '1000.times {|i| puts("b" * 1000)}' > fifo & | |
ruby -e '1000.times {|i| puts("c" * 1000)}' > fifo & | |
ruby -e '1000.times {|i| puts("d" * 1000)}' > fifo & | |
ruby -e '1000.times {|i| puts("e" * 1000)}' > fifo & | |
ruby -e '1000.times {|i| puts("f" * 1000)}' > fifo & | |
ruby -e '1000.times {|i| puts("g" * 1000)}' > fifo & | |
ruby -e '1000.times {|i| puts("h" * 1000)}' > fifo & | |
ruby -e ' | |
counts = Hash.new(0) | |
while line = gets | |
counts[line.chomp("\n")] += 1 | |
end | |
puts counts.length | |
' < fifo | |
rm fifo |
This file contains hidden or 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
#!/bin/bash | |
# > 8 | |
mkfifo fifo | |
ruby -e '$stdout.sync = true; 100000.times {|i| puts "a"}' > fifo & | |
ruby -e '$stdout.sync = true; 100000.times {|i| puts "b"}' > fifo & | |
ruby -e '$stdout.sync = true; 100000.times {|i| puts "c"}' > fifo & | |
ruby -e '$stdout.sync = true; 100000.times {|i| puts "d"}' > fifo & | |
ruby -e '$stdout.sync = true; 100000.times {|i| puts "e"}' > fifo & | |
ruby -e '$stdout.sync = true; 100000.times {|i| puts "f"}' > fifo & | |
ruby -e '$stdout.sync = true; 100000.times {|i| puts "g"}' > fifo & | |
ruby -e '$stdout.sync = true; 100000.times {|i| puts "h"}' > fifo & | |
ruby -e ' | |
counts = Hash.new(0) | |
while line = gets | |
counts[line.chomp("\n")] += 1 | |
end | |
puts counts.length | |
' < fifo | |
rm fifo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks, this is what I suspected...looking for answers here:
https://stackoverflow.com/questions/49937798/how-to-multiplex-named-pipe-fifo