From: Mazet Laurent Date: Tue, 6 May 2025 15:29:32 +0000 (+0200) Subject: correct kill task function X-Git-Tag: v1.0~29^2~13 X-Git-Url: https://secure.softndesign.org/git/?a=commitdiff_plain;h=12ade904f3d87a19a5b8ad6fa2d3a6aa2dc59449;p=morep.git correct kill task function --- 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);