Project

General

Profile

Bug #15735

Thread#handle_interrupt does not prevent Thread#kill from interrupting

Added by inoueyu (Yuki INOUE) 23 days ago. Updated 23 days ago.

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

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?

History

Updated by Eregon (Benoit Daloze) 23 days ago

If that is the case, that might also mean the fix in https://bugs.ruby-lang.org/issues/14998 might not be sufficient.

Also available in: Atom PDF