public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] prctl: pdeath_signal sent when parent thread (instead of parent process) dies
@ 2012-05-29 22:59 Filipe Brandenburger
  2012-06-01 19:02 ` Oleg Nesterov
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Filipe Brandenburger @ 2012-05-29 22:59 UTC (permalink / raw)
  To: Oleg Nesterov, Tejun Heo, Andrew Morton, David Rientjes,
	Peter Zijlstra
  Cc: linux-kernel, Filipe Brandenburger

On a case where a child process uses prctl(PR_SET_PDEATHSIG, signo) to
request that it is sent a signal when the parent process dies, if that
child process was forked by a thread of a multi-threaded process, then
it will receive the signal when the thread terminates, when in fact it
is interested on whether the parent process died instead.

When a process is forked, it is added to the children to the task_struct
that forked it, so that will be the thread that did it. When the thread
terminates, forget_original_parent() will reparent the children by
assigning them a new reaper. In the case of a multi-threaded process,
the new reaper will be another thread in the same thread group.

The patch just adds another check to the case where pdeath_signal is set
in forget_original_parent() to verify whether the tgid of the original
and new parent process are the same and to skip sending the signal in
that particular case.

For more discussion and test cases executed:
https://bugzilla.kernel.org/show_bug.cgi?id=43300

Signed-off-by: Filipe Brandenburger <filbranden@gmail.com>
---
 kernel/exit.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/kernel/exit.c b/kernel/exit.c
index 910a071..ed439cd 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -806,7 +806,8 @@ static void forget_original_parent(struct task_struct *father)
 				BUG_ON(t->ptrace);
 				t->parent = t->real_parent;
 			}
-			if (t->pdeath_signal)
+			if (t->pdeath_signal &&
+			    !same_thread_group(father, reaper))
 				group_send_sig_info(t->pdeath_signal,
 						    SEND_SIG_NOINFO, t);
 		} while_each_thread(p, t);
-- 
1.7.7.6


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-06-15  3:57 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-29 22:59 [PATCH 1/1] prctl: pdeath_signal sent when parent thread (instead of parent process) dies Filipe Brandenburger
2012-06-01 19:02 ` Oleg Nesterov
2012-06-01 20:00   ` Filipe Brandenburger
2012-06-04 16:15     ` Oleg Nesterov
2012-06-12  1:28 ` [PATCHv2 0/1] prctl: move pdeath_signal from task_struct to signal_struct Filipe Brandenburger
2012-06-12  1:28 ` [PATCHv2 1/1] " Filipe Brandenburger
2012-06-12 16:19   ` Oleg Nesterov
2012-06-13 15:46     ` Albert Cahalan
2012-06-15  3:57       ` Filipe Brandenburger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox