summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
Diffstat (limited to 'components')
-rw-r--r--components/lwp/lwp_pid.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/components/lwp/lwp_pid.c b/components/lwp/lwp_pid.c
index e26dfe2017..2b1a342c67 100644
--- a/components/lwp/lwp_pid.c
+++ b/components/lwp/lwp_pid.c
@@ -1308,9 +1308,17 @@ static void _resr_cleanup(struct rt_lwp *lwp)
/** @note safe since the slist node is release */
LWP_UNLOCK(lwp);
LWP_LOCK(child);
- child->sibling = RT_NULL;
- /* info: this may cause an orphan lwp */
- child->parent = RT_NULL;
+ if (child->terminated)
+ {
+ lwp_pid_put(child);
+ }
+ else
+ {
+ child->sibling = RT_NULL;
+ /* info: this may cause an orphan lwp */
+ child->parent = RT_NULL;
+ }
+
LWP_UNLOCK(child);
lwp_ref_dec(child);
lwp_ref_dec(lwp);