[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Timeout when reading from a pipe

Ema Fuma

6/23/2008 2:31:00 PM

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-....

3 Answers

ara.t.howard

6/23/2008 2:35:00 PM

0


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

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://codeforp...
--
we can deny everything, except that we have the possibility of being
better. simply reflect on that.
h.h. the 14th dalai lama




Ema Fuma

6/23/2008 3:48:00 PM

0


> 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-....

Ema Fuma

6/28/2008 11:14:00 AM

0

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-....