From 12ade904f3d87a19a5b8ad6fa2d3a6aa2dc59449 Mon Sep 17 00:00:00 2001 From: Mazet Laurent Date: Tue, 6 May 2025 17:29:32 +0200 Subject: [PATCH] correct kill task function --- task.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/task.c b/task.c index cf655d2..e84de04 100644 --- a/task.c +++ b/task.c @@ -336,7 +336,13 @@ task_t *create_async_task (const char *name, int (*task) (sub_task_t *, int), void kill_all_subtasks (task_t *t, int sig) { for (int i = 0; i < t->nb_sub_tasks; i++) { - pthread_kill (t->sub_task_list[i].thread, sig); + pthread_cancel (t->sub_task_list[i].thread); + void *res; + pthread_join (t->sub_task_list[i].thread, &res); + if (res != PTHREAD_CANCELED) { + VERBOSE (coretools, WARNING, PRINTF ("can't cancel thread %ld\n", t->sub_task_list[i].thread)); + pthread_kill (t->sub_task_list[i].thread, sig); + } } free (t->sub_task_list); free (t); -- 2.30.2