[PATCH] fix (CLONE_PTRACE & !CLONE_PARENT) behavior

From: Mike Coleman (mkc@kc.net)
Date: Mon Mar 13 2000 - 18:52:08 EST


This patch fixes parenting upon fork in the (CLONE_PTRACE & !CLONE_PARENT)
case.

Currently, if A is ptrace-ing B which forks C using CLONE_PTRACE, C reports
its ptrace stops to B, which is useless. This patch makes C report to A.
Without it, CLONE_PTRACE can't be used to follow the "fork" and "vfork"
variants of clone.

--Mike

--- linux-2.3.51/kernel/fork.c.orig Sat Mar 11 18:56:41 2000
+++ linux-2.3.51/kernel/fork.c Sat Mar 11 18:58:03 2000
@@ -647,8 +647,11 @@
         p->run_list.next = NULL;
         p->run_list.prev = NULL;
 
- if ((clone_flags & CLONE_VFORK) || !(clone_flags & CLONE_PARENT))
- p->p_pptr = p->p_opptr = current;
+ if ((clone_flags & CLONE_VFORK) || !(clone_flags & CLONE_PARENT)) {
+ p->p_opptr = current;
+ if (!(current->flags & PF_PTRACED))
+ p->p_pptr = current;
+ }
         p->p_cptr = NULL;
         init_waitqueue_head(&p->wait_chldexit);
         p->vfork_sem = NULL;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Mar 15 2000 - 21:00:28 EST