Issue #16087 has been updated by nobu (Nobuyoshi Nakada).

Status changed from Open to Third Party's Issue

This was due to the limit of mintty.
There can be a chance that this will be solved by mintty (and other terminal emulators for Windows) using Windows Pseudo Console in the future, I guess.

----------------------------------------
Bug #16087: Signal.trap(:INT) doesn't work  on msys2 mingw64 ?
https://bugs.ruby-lang.org/issues/16087#change-80554

* Author: roswell (Takahiro Yamaguchi)
* Status: Third Party's Issue
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.6.3p62 (2019-04-16 revision 67580) [x64-mingw32]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
My environment is Windows 10 msys2 mingw64

```
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]
```

My script is 

```
yama@JPC00183513 ~/b/p/sample> cat signal.rb
# coding: utf-8
$stdout.sync = true

p Signal.list

# EXIT       mignw fail
# INT w pass mingw fail
# QUIT       mingw unsupported signal `SIGQUIT' (ArgumentError)
# ILL        mingw can't trap reserved signal: SIGILL (ArgumentError)
# ABRT       mingw fail
# FPE        mingw can't trap reserved signal: SIGFPE (ArgumentError)
# KILL       mingw Invalid argument - SIGKILL (Errno::EINVAL)
# TERM       mingw fail
Signal.trap(:INT) {
 puts "まわって"
 puts "まわって"
 puts "まわって"
 exit
}

while true
 puts "とんで"
 sleep 3
end
```

Execute the above script, then type C-c to interrupt it

```
yama@JPC00183513 ~/b/p/sample> ruby signal.rb
{"EXIT"=>0, "INT"=>2, "ILL"=>4, "ABRT"=>22, "FPE"=>8, "KILL"=>9, "SEGV"=>11, "TERM"=>15}
とんで
とんで
yama@JPC00183513 ~/b/p/sample>
```

The "Signal.trap(:INT)" block is NOT executed.

I assume the ruby msys2 mingw64 have a bug around Signal handling.




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>