Project

General

Profile

Actions

Bug #15735

closed

Thread#handle_interrupt does not prevent Thread#kill from interrupting

Added by inoueyu (Yuki INOUE) almost 5 years ago. Updated almost 3 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
2.6.2p47 (2019-03-13 revision 67232) [x86_64-darwin18]
[ruby-core:92038]
Tags:

Description

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.

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?

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0