]> granicus.if.org Git - strace/commitdiff
process.c: perform bpt trick for clone as well so we can get the pid of the child...
authorWichert Akkerman <wichert@deephackmode.org>
Sun, 3 Sep 2000 21:56:29 +0000 (21:56 +0000)
committerWichert Akkerman <wichert@deephackmode.org>
Sun, 3 Sep 2000 21:56:29 +0000 (21:56 +0000)
file.c: rename dirent64 struct to kernel_dirent64 so things compile again with newer libcs

ChangeLog
file.c
process.c
test/clone.c

index 7f6d438198e6bbc48819cc7f5a36dada2dc3a4f8..114c2220b96e23a7085972fa1b95f2ca72765317 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2000-09-03  Wichert Akkerman <wakkerma@debian.org>
+
+  *  process.c: perform bpt trick for clone as well so we can get the
+     pid of the child before it starts doing something
+  *  file.c: rename dirent64 struct to kernel_dirent64 so things compile
+     again with newer libcs
+
 2000-09-01  Wichert Akkerman <wakkerma@debian.org>
 
   *  lots of files: merge patch from GaĆ«l Roualland to add
diff --git a/file.c b/file.c
index a74beda9c47dfbff08c4e3ce9ce2c17e9b617e66..911090c89b6bf357ddbb30ba647072643dba5de9 100644 (file)
--- a/file.c
+++ b/file.c
@@ -35,6 +35,7 @@
 #include <dirent.h>
 #ifdef linux
 #define dirent kernel_dirent
+#define dirent64 kernel_dirent64
 #include <linux/types.h>
 #include <linux/dirent.h>
 #undef dirent
index dda3b9eef61fb6abdd4a08bf069816f65f363c88..47fc87d24813fef0e7e50b8b161a82121c327be9 100644 (file)
--- a/process.c
+++ b/process.c
@@ -548,12 +548,18 @@ struct tcb *tcp;
                }
                tcp->flags |= TCB_FOLLOWFORK;
 
-               tcp->u_arg[0] |= CLONE_PTRACE;
-               setarg(tcp, 0);
+
+               if (setbpt(tcp) < 0)
+                       return 0;
        } else {
+               int bpt = tcp->flags & TCB_BPTSET;
+
                if (!(tcp->flags & TCB_FOLLOWFORK))
                        return 0;
 
+               if (bpt)
+                       clearbpt(tcp);
+
                if (syserror(tcp))
                        return 0;
 
@@ -564,10 +570,21 @@ struct tcb *tcp;
                        return 0;
                }
 
-               /* For fork we need to re-attach, but thanks to CLONE_PTRACE we're
-                * already attached.
-                */
+               /* Attach to the new child */
+               if (ptrace(PTRACE_ATTACH, pid, (char *) 1, 0) < 0) {
+                       perror("PTRACE_ATTACH");
+                       fprintf(stderr, "Too late?\n");
+                       droptcb(tcpchild);
+                       return 0;
+               }
+
                tcpchild->flags |= TCB_ATTACHED;
+               if (bpt) {
+                       tcpchild->flags |= TCB_BPTSET;
+                       tcpchild->baddr = tcp->baddr;
+                       memcpy(tcpchild->inst, tcp->inst,
+                               sizeof tcpchild->inst);
+               }
                newoutf(tcpchild);
                tcp->nchildren++;
                if (!qflag)
index 1395b6b95ba2f968b8f09a9d7a6db531a397bd14..75bc54516c5bd32770f62d0f3d914ecff370a668 100644 (file)
@@ -10,7 +10,7 @@ int
 main()
 {
        char    stack[4096];
-       if (clone(child, stack+4000, CLONE_VM|CLONE_FS|CLONE_FILES, NULL) != 0)
-               write(1, "original\n", 9);
+       clone(child, stack+4000, CLONE_VM|CLONE_FS|CLONE_FILES, NULL);
+       write(1, "original\n", 9);
        exit(0);
 }