Timeout when reading from a pipe

M

Me Me

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
 
A

ara.t.howard

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

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/
 
M

Me Me

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
 
M

Me Me

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top