diff --git a/sched/pthread/pthread_create.c b/sched/pthread/pthread_create.c index 8cfab5908fa..70fb9025919 100644 --- a/sched/pthread/pthread_create.c +++ b/sched/pthread/pthread_create.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/pthread/pthread_create.c * - * Copyright (C) 2007-2009, 2011, 2013-2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011, 2013-2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -241,6 +241,9 @@ int pthread_create(FAR pthread_t *thread, FAR const pthread_attr_t *attr, int errcode; pid_t pid; int ret; +#ifdef HAVE_TASK_GROUP + bool group_joined = false; +#endif /* If attributes were not supplied, use the default attributes */ @@ -368,6 +371,8 @@ int pthread_create(FAR pthread_t *thread, FAR const pthread_attr_t *attr, errcode = ENOMEM; goto errout_with_join; } + + group_joined = true; #endif /* Attach the join info to the TCB. */ @@ -451,6 +456,15 @@ errout_with_join: ptcb->joininfo = NULL; errout_with_tcb: +#ifdef HAVE_TASK_GROUP + /* Clear group binding */ + + if (ptcb && !group_joined) + { + ptcb->cmn.group = NULL; + } +#endif + sched_releasetcb((FAR struct tcb_s *)ptcb, TCB_FLAG_TTYPE_PTHREAD); return errcode; }