summaryrefslogtreecommitdiff
path: root/coroutine
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2021-07-02 09:52:56 +1200
committerSamuel Williams <samuel.williams@oriontransfer.co.nz>2021-07-02 12:36:14 +1200
commit1862d961a9b18acbf30d9391e091d91de9c0f16d (patch)
treebc410790ee8f4d54c1727d3c65e2efec23e2b7aa /coroutine
parentb8da141d3223a5b7f3386742bd513aa1fbc6fa4f (diff)
Ignore dead threads in `coroutine_join`.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4620
Diffstat (limited to 'coroutine')
-rw-r--r--coroutine/pthread/Context.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/coroutine/pthread/Context.c b/coroutine/pthread/Context.c
index bbf2d4c1a9..38774cda0b 100644
--- a/coroutine/pthread/Context.c
+++ b/coroutine/pthread/Context.c
@@ -237,9 +237,13 @@ struct coroutine_context * coroutine_transfer(struct coroutine_context * current
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",