[前][次][番号順一覧][スレッド一覧]

ruby-changes:65822

From: Jeremy <ko1@a...>
Date: Fri, 9 Apr 2021 00:01:10 +0900 (JST)
Subject: [ruby-changes:65822] 5c4ff3f00c (master): Document how to handle kill/terminate interrupts in Thread.handle_interrupt

https://git.ruby-lang.org/ruby.git/commit/?id=5c4ff3f00c

From 5c4ff3f00c6bd84ef0721c1077ee9c525daa68f8 Mon Sep 17 00:00:00 2001
From: Jeremy Evans <code@j...>
Date: Thu, 8 Apr 2021 07:53:06 -0700
Subject: Document how to handle kill/terminate interrupts in
 Thread.handle_interrupt

The kill/terminate interrupts are internally handled not as Exception
instances, but as integers.  So using Exception doesn't handle these
interrupts, but Object does.  You can use Integer if you only want to
handle kill/terminate interrupts, but that's probably more of an
implementation detail, while handling Object should work regardless
of the implementation.

Fixes [Bug #15735]
---
 thread.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/thread.c b/thread.c
index 2f5e279..4f2debd 100644
--- a/thread.c
+++ b/thread.c
@@ -2223,6 +2223,8 @@ handle_interrupt_arg_check_i(VALUE key, VALUE val, VALUE args) https://github.com/ruby/ruby/blob/trunk/thread.c#L2223
  *     # all exceptions inherited from Exception are prohibited.
  *   }
  *
+ * For handling all interrupts, use +Object+ and not +Exception+
+ * as the ExceptionClass, as kill/terminate interrupts are not handled by +Exception+.
  */
 static VALUE
 rb_thread_s_handle_interrupt(VALUE self, VALUE mask_arg)
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]