Skip to content

Commit 45f3cf7

Browse files
committed
[kernel] sync with pthread_exit issue in master
1 parent 24fee46 commit 45f3cf7

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/thread.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -326,17 +326,17 @@ rt_err_t rt_thread_detach(rt_thread_t thread)
326326
/* change stat */
327327
thread->stat = RT_THREAD_CLOSE;
328328

329-
/* detach object */
330-
rt_object_detach((rt_object_t)thread);
331-
332-
if (thread->cleanup != RT_NULL)
329+
if ((rt_object_is_systemobject((rt_object_t)thread) == RT_TRUE) &&
330+
thread->cleanup == RT_NULL)
331+
{
332+
rt_object_detach((rt_object_t)thread);
333+
}
334+
else
333335
{
334336
/* disable interrupt */
335337
lock = rt_hw_interrupt_disable();
336-
337338
/* insert to defunct thread list */
338339
rt_list_insert_after(&rt_thread_defunct, &(thread->tlist));
339-
340340
/* enable interrupt */
341341
rt_hw_interrupt_enable(lock);
342342
}
@@ -345,7 +345,6 @@ rt_err_t rt_thread_detach(rt_thread_t thread)
345345
}
346346
RTM_EXPORT(rt_thread_detach);
347347

348-
349348
#ifdef RT_USING_HEAP
350349
/**
351350
* This function will create a thread object and allocate thread object memory

0 commit comments

Comments
 (0)