D
Derek Lewis
I don't know if this is a new bug, known bug, or some sort of feature...
When I try to open a fifo, the entire ruby interpreter locks until
something else opens the other "end" of the fifo. Here's some example
code:
FIFO_FILE='/tmp/rubyfifo'
`mkfifo "#{FIFO_FILE}"` unless test(?e, FIFO_FILE)
thread = Thread.new {
puts "Opening fifo for writing"
File.open(FIFO_FILE, 'w') { |file|
puts "Starting write loop"
while true
puts "Thread is running"
sleep 1
file.puts "Thread is running"
end
}
}
puts "Opening fifo for reading"
File.open(FIFO_FILE, 'r') { |file|
puts "Reading from fifo"
file.each_line { |line|
puts "Read from fifo: #{line}"
}
}
The only output I see from this is "Opening fifo for writing".
If the thread is changed to:
thread = Thread.new {
puts "Starting loop"
while true
puts "Thread is running"
sleep 1
end
}
Then instead, I see this output:
Starting loop
Thread is running
Opening fifo for reading
And I don't see "Thread is running" until I execute this in another
shell:
cat > /tmp/rubyfifo
As soon as I close the cat, the ruby program exits nicely.
Derek Lewis
===================================================================
Java Web-Application Developer
Email : (e-mail address removed)
Cellular : 604.312.2846
Website : http://www.lewisd.com
"If you've got a 5000-line JSP page that has "all in one" support
for three input forms and four follow-up screens, all controlled
by "if" statements in scriptlets, well ... please don't show it
to me
. Its almost dinner time, and I don't want to lose my
appetite
."
- Craig R. McClanahan
When I try to open a fifo, the entire ruby interpreter locks until
something else opens the other "end" of the fifo. Here's some example
code:
FIFO_FILE='/tmp/rubyfifo'
`mkfifo "#{FIFO_FILE}"` unless test(?e, FIFO_FILE)
thread = Thread.new {
puts "Opening fifo for writing"
File.open(FIFO_FILE, 'w') { |file|
puts "Starting write loop"
while true
puts "Thread is running"
sleep 1
file.puts "Thread is running"
end
}
}
puts "Opening fifo for reading"
File.open(FIFO_FILE, 'r') { |file|
puts "Reading from fifo"
file.each_line { |line|
puts "Read from fifo: #{line}"
}
}
The only output I see from this is "Opening fifo for writing".
If the thread is changed to:
thread = Thread.new {
puts "Starting loop"
while true
puts "Thread is running"
sleep 1
end
}
Then instead, I see this output:
Starting loop
Thread is running
Opening fifo for reading
And I don't see "Thread is running" until I execute this in another
shell:
cat > /tmp/rubyfifo
As soon as I close the cat, the ruby program exits nicely.
Derek Lewis
===================================================================
Java Web-Application Developer
Email : (e-mail address removed)
Cellular : 604.312.2846
Website : http://www.lewisd.com
"If you've got a 5000-line JSP page that has "all in one" support
for three input forms and four follow-up screens, all controlled
by "if" statements in scriptlets, well ... please don't show it
to me
appetite
- Craig R. McClanahan