[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Ruby Program dont STOP

Magician White

1/26/2008 3:40:00 PM

Hi, I'm new in Ruby and i found a little problem, make a simple program
with a infinite loop to print one String. I use linux (Kubuntu) and when
i try stop the program whit CTRL+C nothing happen the program dont stop
only when i execute the KILL command the program stop.
I do something wrong ?? How to solve this ?
--
Posted via http://www.ruby-....

6 Answers

Joachim Glauche

1/26/2008 4:07:00 PM

0

Magician White wrote:
> Hi, I'm new in Ruby and i found a little problem, make a simple program
> with a infinite loop to print one String. I use linux (Kubuntu) and when
> i try stop the program whit CTRL+C nothing happen the program dont stop
> only when i execute the KILL command the program stop.
> I do something wrong ?? How to solve this ?

Check on your terminal if there is any key binding for CRTL+C like "Copy
to Clipboard".
--
Posted via http://www.ruby-....

Magician White

1/26/2008 4:08:00 PM

0

Joachim Glauche wrote:
> Magician White wrote:
>> Hi, I'm new in Ruby and i found a little problem, make a simple program
>> with a infinite loop to print one String. I use linux (Kubuntu) and when
>> i try stop the program whit CTRL+C nothing happen the program dont stop
>> only when i execute the KILL command the program stop.
>> I do something wrong ?? How to solve this ?
>
> Check on your terminal if there is any key binding for CRTL+C like "Copy
> to Clipboard".

No CTRL+C stop processes i use it in all other programs.
Only with Ruby dont work.
--
Posted via http://www.ruby-....

Joachim Glauche

1/26/2008 4:15:00 PM

0

Magician White wrote:

> No CTRL+C stop processes i use it in all other programs.
> Only with Ruby dont work.


# cat loop.rb
while true do
puts "test"
sleep 1
end
# ruby loop.rb
test
test
loop.rb:3:in `sleep': Interrupt
from loop.rb:3

One single CTRL+C works fine for me here. I'm using the XFCE terminal.
--
Posted via http://www.ruby-....

Philipp Hofmann

1/26/2008 4:18:00 PM

0


hi,

instead of working with an infinite loop, you could trap the Crtl-C
signal to make your loop come to an end.

stop = false
trap('INT') { stop = true }

until stop
# do your string stuff
end

g phil


On Sun, Jan 27, 2008 at 01:08:10AM +0900, Magician White wrote:
> Joachim Glauche wrote:
> > Magician White wrote:
> >> Hi, I'm new in Ruby and i found a little problem, make a simple program
> >> with a infinite loop to print one String. I use linux (Kubuntu) and when
> >> i try stop the program whit CTRL+C nothing happen the program dont stop
> >> only when i execute the KILL command the program stop.
> >> I do something wrong ?? How to solve this ?
> >
> > Check on your terminal if there is any key binding for CRTL+C like "Copy
> > to Clipboard".
>
> No CTRL+C stop processes i use it in all other programs.
> Only with Ruby dont work.

Magician White

1/26/2008 4:25:00 PM

0

Philipp Hofmann wrote:
> hi,
>
> instead of working with an infinite loop, you could trap the Crtl-C
> signal to make your loop come to an end.
>
> stop = false
> trap('INT') { stop = true }
>
> until stop
> # do your string stuff
> end
>
> g phil

Work perfect :D
Where can i find more info about the trap command ?
--
Posted via http://www.ruby-....

Marc Heiler

1/26/2008 4:47:00 PM

0

> Where can i find more info about the trap command ?

I believe with "ri"

If you dont know ri, look here
http://ruby.about.com/od/gettingstarted/qt/r...

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