On Jun 7, 2006, at 2:17 AM, Dave Burt wrote:

> Logan Capaldo wrote:
>> What ^C is actually depends on your terminal. If ^C is SIGINT for the
>> terminal, you'll never get ^C in the input stream no matter what  
>> you do.
>
> Not true - if you handle the SIGINT, there's no reason why you
> shouldn't get a character in the input stream. Here's an irb session
> on Windows:
>
>>> trap(:INT) {}
> => #<Proc:0x02855d78@C:/Documents and Settings/dburt/Program Files/ 
> ruby/lib/ruby
> /1.8/irb.rb:65>
>>> require "Win32API"
> => true
>>> def read_char
>>>   Win32API.new("crtdll", "_getch", [], "L").Call
>>> end
> => nil
>>> read_char  # and press enter
> => 13
>>> read_char  # and press Ctrl+A
> => 1
>>> read_char  # and press Ctrl+C
> => 3
>
> Cheers,
> Dave
>

Aha. Well I think our respective operating systems have a difference  
of opinion here. Try it on a *NIX. (Note that with a unix terminal  
you could have SIGINT be ^P if you wanted).

^A (the character) will go through but ^C will not because it is  
handled by the terminal, and the terminal simply does a kill(SIGINT)  
on the process, it doesn't write to the processes stdin.