1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Ignore dead threads in coroutine_join.

This commit is contained in:
Samuel Williams 2021-07-02 09:52:56 +12:00
parent b8da141d32
commit 1862d961a9
Notes: git 2021-07-02 09:36:34 +09:00

View file

@ -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",