login
Header Space

 
 

Re: [PATCH 2/2] ptrace children revamp

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Roland McGrath <roland@...>
Cc: Andrew Morton <akpm@...>, Linus Torvalds <torvalds@...>, <linux-kernel@...>
Date: Saturday, March 29, 2008 - 10:37 am

On 03/29, Oleg Nesterov wrote:

Also, I think ptrace_exit() is not right,

	if (p->exit_signal != -1 && !thread_group_empty(p))
		do_notify_parent(p, p->exit_signal);

note the "!thread_group_empty()" above, I guess this is typo, thread group
must be empty if we are going to release the task or notify its parent.


IOW, perhaps something like the patch below makes sense.

Oleg.

--- x/kernel/exit.c~x	2008-03-29 17:14:54.000000000 +0300
+++ x/kernel/exit.c	2008-03-29 17:28:17.000000000 +0300
@@ -596,6 +596,16 @@ static void exit_mm(struct task_struct *
 	mmput(mm);
 }
 
+static void xxx(struct task_struct *p, struct list_head *dead)
+{
+	if (p->exit_state == EXIT_ZOMBIE) {
+		if (p->exit_signal != -1 && thread_group_empty(p))
+			do_notify_parent(p, p->exit_signal);
+		if (p->exit_signal == -1)
+			list_add(&p->ptrace_list, dead);
+	}
+}
+
 /*
  * Detach any ptrace attachees (not our own natural children).
  * Any that need to be release_task'd are put on the @dead list.
@@ -616,12 +626,7 @@ static void ptrace_exit(struct task_stru
 		 * reap itself, add it to the @dead list.  We can't call
 		 * release_task() here because we already hold tasklist_lock.
 		 */
-		if (p->exit_state == EXIT_ZOMBIE) {
-			if (p->exit_signal != -1 && !thread_group_empty(p))
-				do_notify_parent(p, p->exit_signal);
-			if (p->exit_signal == -1)
-				list_add(&p->ptrace_list, dead);
-		}
+		 xxx(p, dead);
 	}
 }
 
@@ -661,13 +666,6 @@ static void reparent_thread(struct task_
 	if (p->exit_signal != -1)
 		p->exit_signal = SIGCHLD;
 
-	/* If we'd notified the old parent about this child's death,
-	 * also notify the new parent.
-	 */
-	if (p->exit_state == EXIT_ZOMBIE &&
-	    p->exit_signal != -1 && thread_group_empty(p))
-		do_notify_parent(p, p->exit_signal);
-
 	/*
 	 * process group orphan check
 	 * Case ii: Our child is in a different pgrp
@@ -720,6 +718,7 @@ static void forget_original_parent(struc
 			p->parent = p->real_parent;
 		}
 		reparent_thread(p, father);
+		xxx(p, &ptrace_dead);
 	}
 
 	write_unlock_irq(&tasklist_lock);

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 1/2] do_wait reorganization, Roland McGrath, (Fri Mar 28, 11:34 pm)
Re: [PATCH 1/2] do_wait reorganization, Linus Torvalds, (Sat Mar 29, 12:16 pm)
[PATCH 1/3] do_wait reorganization, Roland McGrath, (Sun Mar 30, 11:57 pm)
Re: [PATCH 1/3] do_wait reorganization, Oleg Nesterov, (Mon Mar 31, 4:51 am)
Re: [PATCH 1/3] do_wait reorganization, Roland McGrath, (Mon Mar 31, 4:29 pm)
Re: [PATCH 1/3] do_wait reorganization, Oleg Nesterov, (Mon Mar 31, 4:07 pm)
[PATCH 2/3] ptrace children revamp, Roland McGrath, (Sun Mar 30, 11:59 pm)
Re: [PATCH 2/3] ptrace children revamp, Oleg Nesterov, (Mon Mar 31, 5:12 am)
Re: [PATCH 1/2] do_wait reorganization, Roland McGrath, (Sun Mar 30, 11:27 pm)
Re: [PATCH 1/2] do_wait reorganization, Oleg Nesterov, (Sat Mar 29, 6:35 am)
Re: [PATCH 1/2] do_wait reorganization, Roland McGrath, (Sun Mar 30, 11:54 pm)
[PATCH 2/2] ptrace children revamp, Roland McGrath, (Fri Mar 28, 11:35 pm)
Re: [PATCH 2/2] ptrace children revamp, Oleg Nesterov, (Sat Mar 29, 6:39 am)
Re: [PATCH 2/2] ptrace children revamp, Oleg Nesterov, (Sat Mar 29, 9:10 am)
Re: [PATCH 2/2] ptrace children revamp, Roland McGrath, (Fri Apr 4, 5:00 pm)
Re: [PATCH 2/2] ptrace children revamp, Oleg Nesterov, (Sat Apr 5, 10:06 am)
Re: [PATCH 2/2] ptrace children revamp, Roland McGrath, (Wed Apr 9, 4:15 pm)
Re: [PATCH 2/2] ptrace children revamp, Oleg Nesterov, (Sun Apr 13, 10:24 am)
Re: [PATCH 2/2] ptrace children revamp, Roland McGrath, (Mon Apr 14, 9:41 pm)
Re: [PATCH 2/2] ptrace children revamp, Oleg Nesterov, (Sat Mar 29, 10:37 am)
speck-geostationary