ruby-changes:66661
From: Samuel <ko1@a...>
Date: Fri, 2 Jul 2021 09:36:26 +0900 (JST)
Subject: [ruby-changes:66661] 1862d961a9 (master): Ignore dead threads in `coroutine_join`.
https://git.ruby-lang.org/ruby.git/commit/?id=1862d961a9 From 1862d961a9b18acbf30d9391e091d91de9c0f16d Mon Sep 17 00:00:00 2001 From: Samuel Williams <samuel.williams@o...> Date: Fri, 2 Jul 2021 09:52:56 +1200 Subject: Ignore dead threads in `coroutine_join`. --- coroutine/pthread/Context.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/coroutine/pthread/Context.c b/coroutine/pthread/Context.c index bbf2d4c..38774cd 100644 --- a/coroutine/pthread/Context.c +++ b/coroutine/pthread/Context.c @@ -237,9 +237,13 @@ struct coroutine_context * coroutine_transfer(struct coroutine_context * current https://github.com/ruby/ruby/blob/trunk/coroutine/pthread/Context.c#L237 static void coroutine_join(struct coroutine_context * context) { if (DEBUG) fprintf(stderr, "coroutine_join:pthread_cancel\n"); - check("coroutine_join:pthread_cancel", - pthread_cancel(context->id) - ); + int result = pthread_cancel(context->id); + if (result == -1 && errno == ESRCH) { + // The thread may be dead due to fork, so it cannot be joined and this doesn't represent a real error: + return; + } + + check("coroutine_join:pthread_cancel", result); if (DEBUG) fprintf(stderr, "coroutine_join:pthread_join\n"); check("coroutine_join:pthread_join", -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/