Issue #15735 has been reported by inoueyu (Yuki INOUE).

----------------------------------------
Bug #15735: Thread#handle_interrupt does not prevent Thread#kill from interrupting
https://bugs.ruby-lang.org/issues/15735

* Author: inoueyu (Yuki INOUE)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 2.6.2p47 (2019-03-13 revision 67232) [x86_64-darwin18]
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
https://docs.ruby-lang.org/en/trunk/Thread.html#method-c-handle_interrupt

According to the documentation above, `Thread#handle_interrupt(Exception => :never)` would prevent the interrupts from `Thread#kill`.

In the following code, however, the `Thread#kill` seems to just kill the thread immediately even if the thread is instructed to never handle interrupt.

``` ruby
t = Thread.new do
  Thread.handle_interrupt(Exception => :never) do
    puts "thread started"
    sleep 2
    puts "thread end"
  end
end
sleep 1
t.kill
puts "main end"
sleep 2
```

Outputs

```
$ ruby test.rb
thread started
main end
$ 
```

Is the document wrong?  Or, implementation not working as expected?



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