[ruby-list:50808] Re: [質問] msys2 mingw64 ruby Signal.trap(:INT) が動作しない?

From: yamataka@...08.itscom.net
Date: 2019-08-09 00:03:55 UTC
List: ruby-list #50808
On Thu, 08 Aug 2019 23:46:19 +0900,
Takahiro Yamaguchi wrote:
> Signal.trap(:INT) が動作しないので、回避策がないかの質問でした。
> 
> begin
>   loop do
>     sleep 2
>     puts "たこ"
>   end
> rescue =>  Interrupt
>   puts “Interrupt”
> end
> 
> 自宅のMacで動作確認出来たので、
> 明日、会社のWindows msys2 mingw64で、試してみます。
> これで、回避できるかもしれません。


> 明日、会社のWindows msys2 mingw64で、試してみます。

ですが、rescue => Interrupt が動作しないです。

yama@JPC00183513 ~/b/p/sample>
yama@JPC00183513 ~/b/p/sample> uname -a
MINGW64_NT-10.0-17763 JPC00183513 3.0.7-338.x86_64 2019-05-27 06:58 UTC x86_64 Msys
yama@JPC00183513 ~/b/p/sample> ruby --version
ruby 2.6.3p62 (2019-04-16 revision 67580) [x64-mingw32]
yama@JPC00183513 ~/b/p/sample> cat signal2.rb
# coding: utf-8
$stdout.sync = true

begin
  loop do
    sleep 2
    puts "たこ"
  end
rescue =>  Interrupt
  puts “Interrupt”
end
yama@JPC00183513 ~/b/p/sample> ruby signal2.rb
たこ
たこ
たこ

# Ctrl-c  する
# puts "Interrupt" 表示されず
yama@JPC00183513 ~/b/p/sample>

In This Thread