]> granicus.if.org Git - psmisc/commitdiff
peekfd: split follow_forks into follow_clones
authorJeff Smith <whydoubt@gmail.com>
Sat, 23 Sep 2017 06:12:44 +0000 (01:12 -0500)
committerCraig Small <csmall@enc.com.au>
Mon, 13 Aug 2018 11:24:43 +0000 (21:24 +1000)
Signed-off-by: Jeff Smith <whydoubt@gmail.com>
src/peekfd.c

index 46f52a2ee885c06965e559c63856f3d17d6f1685..7cf05e09f2adb139a51ef77a98eb187af0ae6a0a 100644 (file)
@@ -152,6 +152,7 @@ int main(int argc, char **argv)
        int eight_bit_clean = 0;
        int no_headers = 0;
        int follow_forks = 0;
+       int follow_clones = 0;
        int remove_duplicates = 0;
        int optc;
     int target_pid = 0;
@@ -190,6 +191,7 @@ int main(int argc, char **argv)
                                break;
                        case 'c':
                                follow_forks = 1;
+                               follow_clones = 1;
                                break;
                        case 'd':
                                remove_duplicates = 1;
@@ -258,9 +260,10 @@ int main(int argc, char **argv)
                        ptrace(PTRACE_GETREGS, pid, 0, &regs);
 #endif         
                        /*unsigned int b = ptrace(PTRACE_PEEKTEXT, pid, regs.eip, 0);*/
-                       if (follow_forks && (regs.REG_ORIG_ACCUM == SYS_fork || regs.REG_ORIG_ACCUM == SYS_clone)) {
+                       if ((follow_forks && regs.REG_ORIG_ACCUM == SYS_fork)
+                        || (follow_clones && regs.REG_ORIG_ACCUM == SYS_clone)) {
                                if (regs.REG_ACCUM > 0)
-                                       attach(regs.REG_ACCUM);                                 
+                                       attach(regs.REG_ACCUM);
                        }
                        if ((regs.REG_ORIG_ACCUM == SYS_read || regs.REG_ORIG_ACCUM == SYS_write) && (regs.REG_PARAM3 == regs.REG_ACCUM)) {
                                for (i = 0; i < numfds; i++)