From owner-svn-src-head@freebsd.org Sat Feb 17 00:24:51 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2AF8BF20EFD; Sat, 17 Feb 2018 00:24:51 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CDF017AE8C; Sat, 17 Feb 2018 00:24:50 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C90B014FFF; Sat, 17 Feb 2018 00:24:50 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1H0OofI030512; Sat, 17 Feb 2018 00:24:50 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1H0OoYR030511; Sat, 17 Feb 2018 00:24:50 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201802170024.w1H0OoYR030511@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sat, 17 Feb 2018 00:24:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r329422 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 329422 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Feb 2018 00:24:51 -0000 Author: mjg Date: Sat Feb 17 00:24:50 2018 New Revision: 329422 URL: https://svnweb.freebsd.org/changeset/base/329422 Log: On process exit signal the parent after dropping the proctree lock. Modified: head/sys/kern/kern_exit.c Modified: head/sys/kern/kern_exit.c ============================================================================== --- head/sys/kern/kern_exit.c Sat Feb 17 00:23:56 2018 (r329421) +++ head/sys/kern/kern_exit.c Sat Feb 17 00:24:50 2018 (r329422) @@ -193,6 +193,7 @@ exit1(struct thread *td, int rval, int signo) struct proc *p, *nq, *q, *t; struct thread *tdt; ksiginfo_t *ksi, *ksi1; + int signal_parent; mtx_assert(&Giant, MA_NOTOWNED); KASSERT(rval == 0 || signo == 0, ("exit1 rv %d sig %d", rval, signo)); @@ -559,6 +560,7 @@ exit1(struct thread *td, int rval, int signo) * procdesc_exit() to serialize concurrent calls to close() and * exit(). */ + signal_parent = 0; if (p->p_procdesc == NULL || procdesc_exit(p)) { /* * Notify parent that we're gone. If parent has the @@ -588,17 +590,24 @@ exit1(struct thread *td, int rval, int signo) } else mtx_unlock(&p->p_pptr->p_sigacts->ps_mtx); - if (p->p_pptr == p->p_reaper || p->p_pptr == initproc) - childproc_exited(p); - else if (p->p_sigparent != 0) { - if (p->p_sigparent == SIGCHLD) - childproc_exited(p); - else /* LINUX thread */ - kern_psignal(p->p_pptr, p->p_sigparent); + if (p->p_pptr == p->p_reaper || p->p_pptr == initproc) { + signal_parent = 1; + } else if (p->p_sigparent != 0) { + if (p->p_sigparent == SIGCHLD) { + signal_parent = 1; + } else { /* LINUX thread */ + signal_parent = 2; + } } } else PROC_LOCK(p->p_pptr); sx_xunlock(&proctree_lock); + + if (signal_parent == 1) { + childproc_exited(p); + } else if (signal_parent == 2) { + kern_psignal(p->p_pptr, p->p_sigparent); + } /* Tell the prison that we are gone. */ prison_proc_free(p->p_ucred->cr_prison);