From af7f61db496da0ef2e3ddc79075dd7c9ec933daf Mon Sep 17 00:00:00 2001 From: Masamichi Takagi Date: Sun, 2 Sep 2018 17:10:13 +0900 Subject: [PATCH] uti: mcexec: Fix error check of pthread_detach Change-Id: Idda8e060641bbd7b01c50163140a2c5f7466d193 --- executer/user/mcexec.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/executer/user/mcexec.c b/executer/user/mcexec.c index dc114e8f..71f7594b 100644 --- a/executer/user/mcexec.c +++ b/executer/user/mcexec.c @@ -3283,11 +3283,12 @@ util_thread(struct thread_data_s *my_thread, unsigned long uctx_pa, int remote_t ioctl(fd, MCEXEC_UP_UTI_ATTR, &desc); } - /* Synchronize detached state with the McKernel counterpart */ - if ((rc = pthread_detach(my_thread->thread_id)) != 0) { - fprintf(stderr, "%s: pthread_detach returned %d\n", __FUNCTION__, rc); + /* McKernel would create the thread detached, so detach myself */ + if ((rc = pthread_detach(my_thread->thread_id)) < 0) { + fprintf(stderr, "%s: ERROR pthread_detach returned %d\n", __FUNCTION__, rc); + goto out; } - my_thread->detached = 1; /* Skip join in join_all_threads() */ + my_thread->detached = 1; if ((rc = switch_ctx(fd, MCEXEC_UP_UTIL_THREAD2, param, lctx, rctx)) < 0) {