Ruby Program dont STOP

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-forum.com/.

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-forum.com/\.

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-forum.com/\.

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-forum.com/\.

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.

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 :smiley:
Where can i find more info about the trap command ?

···

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

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/ruby_ri.htm

···

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