Z
Zundra Daniel
[Note: parts of this message were removed to make it a legal post.]
I realize this is a Ruby mailing list but I have a Ruby/Rails question that
seems to fall more on the Ruby side of the fence. I have a library file
that creates a named pipe and writes the results of ping to the pipe. This
method is called via a get AJAX request to kick off the process.
def self.run(address)
Fifo.open(PINGFIFO)
Thread.new {
IO.popen "ping -c 10 localhost" do |f|
until f.eof?
Fifo.write(f.gets, PINGFIFO)
end
end
}
end
Then in a 2nd AJAX request I simply attempt to read the named pipe and
return the string to the browser:
def results
if File.exists?(PINGFIFO) && File.pipe?(PINGFIFO)
File.open(PINGFIFO, "r") do |f|
render :text => f.readlines
end
end
end
The problem is the 2nd AJAX request simply hangs indefinitely. If I tail
the pipe I can see data being written to it. Does anyone have any insight
into why this is happening? It seemed like a simple enough problem but this
one is throwing me for a loop (har!).
I realize this is a Ruby mailing list but I have a Ruby/Rails question that
seems to fall more on the Ruby side of the fence. I have a library file
that creates a named pipe and writes the results of ping to the pipe. This
method is called via a get AJAX request to kick off the process.
def self.run(address)
Fifo.open(PINGFIFO)
Thread.new {
IO.popen "ping -c 10 localhost" do |f|
until f.eof?
Fifo.write(f.gets, PINGFIFO)
end
end
}
end
Then in a 2nd AJAX request I simply attempt to read the named pipe and
return the string to the browser:
def results
if File.exists?(PINGFIFO) && File.pipe?(PINGFIFO)
File.open(PINGFIFO, "r") do |f|
render :text => f.readlines
end
end
end
The problem is the 2nd AJAX request simply hangs indefinitely. If I tail
the pipe I can see data being written to it. Does anyone have any insight
into why this is happening? It seemed like a simple enough problem but this
one is throwing me for a loop (har!).