Timeout when reading from a pipe

Hi,
I would like to launch a process (external executable) and raise an
exception if I cannot read any output from it on the stdout.
Is that possible?

Thanks in advance

def execute_mencoder(command)
  IO.popen(command) do |pipe|
   pipe.each("\r") do |line|
         puts line
   end
  end
  raise MediaFormatException if $?.exitstatus != 0
end

···

--
Posted via http://www.ruby-forum.com/.

if you are windows no, otherwise yes.

ri Timeout

if you are on windows you'll want the systemu gem

gem install systemu

regards.

a @ http://codeforpeople.com/

···

On Jun 23, 2008, at 8:30 AM, Me Me wrote:

Hi,
I would like to launch a process (external executable) and raise an
exception if I cannot read any output from it on the stdout.
Is that possible?

Thanks in advance

def execute_mencoder(command)
IO.popen(command) do |pipe|
  pipe.each("\r") do |line|
        puts line
  end
end
raise MediaFormatException if $?.exitstatus != 0
end

--
we can deny everything, except that we have the possibility of being better. simply reflect on that.
h.h. the 14th dalai lama

if you are windows no, otherwise yes.

Ok, we discussed about that but it was in another thread.
So, it's not even possible to detect that an external exe launched is
become
a zombie process?
Do I have to resort to threads?
Thans again

···

--
Posted via http://www.ruby-forum.com/\.

Hi, still on the subject I'm trying to understand if under Windows
I can emit and trap custom signals from two processes.
It should be something like this:

open("|-", "r") do |child|
if child
    child.each("\n") do |line|
  puts line
        # emit signal
  end
  child.close
else
  exec("ls", "-l")
        # trap signal checking a timeout
        # if signal not received for more than 10 secs close child\
        # and go on
end
end

Is there a way to implement what specified in the commented lines?

Thanks in advance

···

--
Posted via http://www.ruby-forum.com/.