[jmc_at_netbsd.org: CVS commit: [netbsd-1-6] src/sys/kern]

From: Pawel Jakub Dawidek <pjd_at_FreeBSD.org>
Date: Sun, 28 Mar 2004 11:25:26 +0200
Hi.

I think this fix is also related to us, isn't it?

----- Forwarded message from James Chacon <jmc_at_netbsd.org> -----

X-Original-To: nick_at_garage.freebsd.pl
Delivered-To: pjd_at_darkness.comp.waw.pl
Delivered-To: source-changes_at_netbsd.org
From: James Chacon <jmc_at_netbsd.org>
Subject: CVS commit: [netbsd-1-6] src/sys/kern
To: source-changes_at_NetBSD.org
Reply-To: jmc_at_netbsd.org
Date: Sun, 28 Mar 2004 08:02:36 +0000 (UTC)
Precedence: list

Commiter:	James Chacon <jmc_at_netbsd.org>
Branch:		netbsd-1-6

Files:
	1.93.6.3   src/sys/kern/kern_exit.c  

Log Message:
Pullup rev 1.104-1.106 (requested by junyoung in ticket #1615)

Make sure that, if orphaned child is being traced, it's reparented back
to the original parent before it's killed.


Diffs:
COMMAND: cvs -d:pserver:anoncvs_at_anoncvs.netbsd.org:/cvsroot rdiff -u -r1.93.6.2 -r1.93.6.3 src/sys/kern/kern_exit.c
Index: src/sys/kern/kern_exit.c
diff -u src/sys/kern/kern_exit.c:1.93.6.2 src/sys/kern/kern_exit.c:1.93.6.3
--- src/sys/kern/kern_exit.c:1.93.6.2	Wed Oct 22 06:15:50 2003
+++ src/sys/kern/kern_exit.c	Sun Mar 28 08:02:36 2004
_at__at_ -1,4 +1,4 _at__at_
-/*	$NetBSD: kern_exit.c,v 1.93.6.2 2003/10/22 06:15:50 jmc Exp $	*/
+/*	$NetBSD: kern_exit.c,v 1.93.6.3 2004/03/28 08:02:36 jmc Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
_at__at_ -78,7 +78,7 _at__at_
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.93.6.2 2003/10/22 06:15:50 jmc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.93.6.3 2004/03/28 08:02:36 jmc Exp $");
 
 #include "opt_ktrace.h"
 #include "opt_sysv.h"
_at__at_ -240,14 +240,25 _at__at_
 		wakeup((caddr_t)initproc);
 	for (; q != 0; q = nq) {
 		nq = q->p_sibling.le_next;
-		proc_reparent(q, initproc);
+
 		/*
-		 * Traced processes are killed
-		 * since their existence means someone is screwing up.
+		 * Traced processes are killed since their existence
+		 * means someone is screwing up. Since we reset the
+		 * trace flags, the logic in sys_wait4() would not be
+		 * triggered to reparent the process to its
+		 * original parent, so we must do this here.
 		 */
 		if (q->p_flag & P_TRACED) {
+			if (q->p_opptr != q->p_pptr) {
+				struct proc *t = q->p_opptr;
+				proc_reparent(q, t ? t : initproc);
+				q->p_opptr = NULL;
+			} else
+				proc_reparent(q, initproc);
 			q->p_flag &= ~(P_TRACED|P_WAITED|P_FSTRACE);
 			psignal(q, SIGKILL);
+		} else {
+			proc_reparent(q, initproc);
 		}
 	}
 
----- End forwarded message -----


-- 
Pawel Jakub Dawidek                       http://www.FreeBSD.org
pjd_at_FreeBSD.org                           http://garage.freebsd.pl
FreeBSD committer                         Am I Evil? Yes, I Am!

Received on Sun Mar 28 2004 - 00:25:28 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:49 UTC