summaryrefslogtreecommitdiff
path: root/task-utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'task-utils.c')
-rw-r--r--task-utils.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/task-utils.c b/task-utils.c
index 10e3f0fc..0390a69f 100644
--- a/task-utils.c
+++ b/task-utils.c
@@ -50,9 +50,7 @@ int task_start(struct task_info *info)
ret = pthread_create(&info->id, NULL, info->threadfn,
info->private_data);
- if (ret == 0)
- pthread_detach(info->id);
- else
+ if (ret)
info->id = -1;
return ret;
@@ -66,8 +64,10 @@ void task_stop(struct task_info *info)
if (info->periodic.timer_fd)
close(info->periodic.timer_fd);
- if (info->id > 0)
+ if (info->id > 0) {
pthread_cancel(info->id);
+ pthread_join(info->id, NULL);
+ }
if (info->postfn)
info->postfn(info->private_data);