Skip to content

Commit

Permalink
Ignore dead threads in coroutine_join.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Jul 2, 2021
1 parent b8da141 commit 1862d96
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions coroutine/pthread/Context.c
Expand Up @@ -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",
Expand Down

0 comments on commit 1862d96

Please sign in to comment.