* process.c [LINUX] (internal_fork): Remove #ifdefs on CLONE_PTRACE
and TCB_CLONE_THREAD.  CLONE_PTRACE is already mandatory for
compilation on Linux in util.c and anyway it's defined earlier in
process.c.  TCB_CLONE_THREAD is always defined if LINUX is.

Signed-off-by: Jamie Lokier <ja...@shareable.org>
---
 process.c |   80 +++++++++++++++++++++++--------------------------------------
 1 files changed, 30 insertions(+), 50 deletions(-)

diff --git a/process.c b/process.c
index c69e45e..6ae08a9 100644
--- a/process.c
+++ b/process.c
@@ -801,6 +801,7 @@ internal_fork(struct tcb *tcp)
                struct tcb *tcpchild;
                int pid;
                int bpt;
+               int call_flags;
 
                if (!(tcp->flags & TCB_FOLLOWFORK))
                        return 0;
@@ -815,7 +816,6 @@ internal_fork(struct tcb *tcp)
 
                pid = tcp->u_rval;
 
-#ifdef CLONE_PTRACE            /* See new setbpt code.  */
                tcpchild = pid2tcb(pid);
                if (tcpchild != NULL) {
                        /* The child already reported its startup trap
@@ -826,26 +826,11 @@ internal_fork(struct tcb *tcp)
                                fprintf(stderr, "\
 [preattached child %d of %d in weird state!]\n",
                                        pid, tcp->pid);
-               }
-               else
-#endif /* CLONE_PTRACE */
-               {
+               } else {
                        fork_tcb(tcp);
                        tcpchild = alloctcb(pid);
                }
 
-#ifndef CLONE_PTRACE
-               /* Attach to the new child */
-               if (ptrace(PTRACE_ATTACH, pid, (char *) 1, 0) < 0) {
-                       if (bpt)
-                               clearbpt(tcp);
-                       perror("PTRACE_ATTACH");
-                       fprintf(stderr, "Too late?\n");
-                       droptcb(tcpchild);
-                       return 0;
-               }
-#endif /* !CLONE_PTRACE */
-
                if (bpt)
                        clearbpt(tcp);
 
@@ -879,40 +864,35 @@ Process %u resumed (parent %d ready)\n",
                                fprintf(stderr, "Process %d attached\n", pid);
                }
 
-#ifdef TCB_CLONE_THREAD
-               {
-                       /*
-                        * Save the flags used in this call,
-                        * in case we point TCP to our parent below.
-                        */
-                       int call_flags = tcp->u_arg[ARG_FLAGS];
-                       if ((tcp->flags & TCB_CLONE_THREAD) &&
-                           tcp->parent != NULL) {
-                               /* The parent in this clone is itself a
-                                  thread belonging to another process.
-                                  There is no meaning to the parentage
-                                  relationship of the new child with the
-                                  thread, only with the process.  We
-                                  associate the new thread with our
-                                  parent.  Since this is done for every
-                                  new thread, there will never be a
-                                  TCB_CLONE_THREAD process that has
-                                  children.  */
-                               --tcp->nchildren;
-                               tcp = tcp->parent;
-                               tcpchild->parent = tcp;
-                               ++tcp->nchildren;
-                       }
-                       if (call_flags & CLONE_THREAD) {
-                               tcpchild->flags |= TCB_CLONE_THREAD;
-                               ++tcp->nclone_threads;
-                       }
-                       if (call_flags & CLONE_DETACHED) {
-                               tcpchild->flags |= TCB_CLONE_DETACHED;
-                               ++tcp->nclone_detached;
-                       }
+               /*
+                * Save the flags used in this call,
+                * in case we point TCP to our parent below.
+                */
+               call_flags = tcp->u_arg[ARG_FLAGS];
+               if ((tcp->flags & TCB_CLONE_THREAD) &&
+                   tcp->parent != NULL) {
+                 /*
+                  * The parent in this clone is itself a thread belonging
+                  * to another process.  There is now meaning to the
+                  * parentage relationship of the new child with the
+                  * thread, only with the process.  We associate the new
+                  * thread with our parent.  Since this is done for every
+                  * new thread, there will never be a TCB_CLONE_THREAD
+                  * process that has children.
+                  */
+                 --tcp->nchildren;
+                 tcp = tcp->parent;
+                 tcpchild->parent = tcp;
+                 ++tcp->nchildren;
+               }
+               if (call_flags & CLONE_THREAD) {
+                 tcpchild->flags |= TCB_CLONE_THREAD;
+                 ++tcp->nclone_threads;
+               }
+               if (call_flags & CLONE_DETACHED) {
+                 tcpchild->flags |= TCB_CLONE_DETACHED;
+                 ++tcp->nclone_detached;
                }
-#endif /* TCB_CLONE_THREAD */
        }
        return 0;
 }
-- 
1.7.0.4

_______________________________________________
uClinux-dev mailing list
uClinux-dev@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev

Reply via email to