[PATCH] Handle CLONE_PARENT flag

Wang Chao wang.chao at cn.fujitsu.com
Thu Aug 5 06:58:37 UTC 2010


* process.c (internal_fork): the parent of new cloned process is the
same of the calling process when CLONE_PARENT is set.
---
 process.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/process.c b/process.c
index bd8037e..bc89b2d 100644
--- a/process.c
+++ b/process.c
@@ -911,6 +911,16 @@ Process %u resumed (parent %d ready)\n",
 				tcpchild->flags |= TCB_CLONE_DETACHED;
 				++tcp->nclone_detached;
 			}
+			if ((call_flags & CLONE_PARENT) &&
+			    !(call_flags & CLONE_THREAD)) {
+				--tcp->nchildren;
+				tcpchild->parent = NULL;
+				if (tcp->parent != NULL) {
+					tcp = tcp->parent;
+					tcpchild->parent = tcp;
+					++tcp->nchildren;
+				}
+			}
 		}
 #endif /* TCB_CLONE_THREAD */
 	}
-- 
1.6.5.2





More information about the Strace-devel mailing list