=== modified file 'fs/exec.c'
--- fs/exec.c	2008-12-11 08:08:07 +0000
+++ fs/exec.c	2008-12-11 08:26:17 +0000
@@ -1016,6 +1016,7 @@
 		suid_keys(current);
 		set_dumpable(current->mm, suid_dumpable);
 		current->pdeath_signal = 0;
+		current->notify_adoption = 0;
 	} else if (file_permission(bprm->file, MAY_READ) ||
 			(bprm->interp_flags & BINPRM_FLAGS_ENFORCE_NONDUMP)) {
 		suid_keys(current);
@@ -1104,6 +1105,7 @@
 	if (bprm->e_uid != current->uid) {
 		suid_keys(current);
 		current->pdeath_signal = 0;
+		current->notify_adoption = 0;
 	}
 	exec_keys(current);
 

=== modified file 'include/asm-generic/siginfo.h'
--- include/asm-generic/siginfo.h	2008-12-11 08:08:07 +0000
+++ include/asm-generic/siginfo.h	2008-12-11 08:35:18 +0000
@@ -210,7 +210,8 @@
 #define CLD_TRAPPED	(__SI_CHLD|4)	/* traced child has trapped */
 #define CLD_STOPPED	(__SI_CHLD|5)	/* child has stopped */
 #define CLD_CONTINUED	(__SI_CHLD|6)	/* stopped child has continued */
-#define NSIGCHLD	6
+#define CLD_ADOPTED     (__SI_CHLD|7)	/* child adopted */
+#define NSIGCHLD	7
 
 /*
  * SIGPOLL si_codes

=== modified file 'include/linux/prctl.h'
--- include/linux/prctl.h	2008-12-11 08:08:07 +0000
+++ include/linux/prctl.h	2008-12-11 08:32:24 +0000
@@ -78,4 +78,8 @@
 #define PR_GET_SECUREBITS 27
 #define PR_SET_SECUREBITS 28
 
+/* Set/get notification of adoption */
+#define PR_SET_NOTIFY_ADOPTION 29
+#define PR_GET_NOTIFY_ADOPTION 30
+
 #endif /* _LINUX_PRCTL_H */

=== modified file 'include/linux/sched.h'
--- include/linux/sched.h	2008-12-11 08:08:07 +0000
+++ include/linux/sched.h	2008-12-11 09:34:36 +0000
@@ -1085,6 +1085,7 @@
 	int exit_state;
 	int exit_code, exit_signal;
 	int pdeath_signal;  /*  The signal sent when the parent dies  */
+	unsigned notify_adoption:1;  /*  Notify adoption of new children  */
 	/* ??? */
 	unsigned int personality;
 	unsigned did_exec:1;

=== modified file 'kernel/exit.c'
--- kernel/exit.c	2008-12-11 08:08:07 +0000
+++ kernel/exit.c	2008-12-11 08:25:31 +0000
@@ -809,6 +809,20 @@
 		/* We already hold the tasklist_lock here.  */
 		group_send_sig_info(p->pdeath_signal, SEND_SIG_NOINFO, p);
 
+	if (p->real_parent->notify_adoption) {
+		struct siginfo info;
+
+		memset(&info, 0, sizeof info);
+		info.si_signo = SIGCHLD;
+		info.si_code = CLD_ADOPTED:
+		info.si_pid = task_pid_vnr(p);
+		info.si_status = task_pid_vnr(father);
+		info.si_uid = p->uid;
+
+		group_send_sig_info(SIGCHLD, &info, p->real_parent);
+
+	}
+
 	list_move_tail(&p->sibling, &p->real_parent->children);
 
 	/* If this is a threaded reparent there is no need to

=== modified file 'kernel/sys.c'
--- kernel/sys.c	2008-12-11 08:08:07 +0000
+++ kernel/sys.c	2008-12-11 08:31:47 +0000
@@ -1727,6 +1727,12 @@
 		case PR_SET_TSC:
 			error = SET_TSC_CTL(arg2);
 			break;
+		case PR_SET_NOTIFY_ADOPTION:
+			current->notify_adoption = arg2 ? 1 : 0;
+			break;
+		case PR_GET_NOTIFY_ADOPTION:
+			error = current->notify_adoption ? 1 : 0;
+			break;
 		default:
 			error = -EINVAL;
 			break;

=== modified file 'security/commoncap.c'
--- security/commoncap.c	2008-12-11 08:08:07 +0000
+++ security/commoncap.c	2008-12-11 08:25:43 +0000
@@ -365,6 +365,7 @@
 			  current->cap_permitted)) {
 		set_dumpable(current->mm, suid_dumpable);
 		current->pdeath_signal = 0;
+		current->notify_adoption = 0;
 
 		if (unsafe & ~LSM_UNSAFE_PTRACE_CAP) {
 			if (!capable(CAP_SETUID)) {

=== modified file 'security/selinux/hooks.c'
--- security/selinux/hooks.c	2008-12-11 08:08:07 +0000
+++ security/selinux/hooks.c	2008-12-11 08:25:59 +0000
@@ -2276,8 +2276,10 @@
 		spin_unlock_irq(&current->sighand->siglock);
 	}
 
-	/* Always clear parent death signal on SID transitions. */
+	/* Always clear parent death signal and adoption notification
+	 * on SID transitions. */
 	current->pdeath_signal = 0;
+	current->notify_adoption = 0;
 
 	/* Check whether the new SID can inherit resource limits
 	   from the old SID.  If not, reset all soft limits to

