Actions
Bug #15735
closedThread#handle_interrupt does not prevent Thread#kill from interrupting
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
2.6.2p47 (2019-03-13 revision 67232) [x86_64-darwin18]
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
Like0
Like0Like0Like0