From owner-svn-src-all@freebsd.org Mon Dec 12 11:11:51 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 90F4CC722E3; Mon, 12 Dec 2016 11:11:51 +0000 (UTC) (envelope-from kib@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 mx1.freebsd.org (Postfix) with ESMTPS id 608F71BB3; Mon, 12 Dec 2016 11:11:51 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBCBBonj086827; Mon, 12 Dec 2016 11:11:50 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBCBBoE3086826; Mon, 12 Dec 2016 11:11:50 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201612121111.uBCBBoE3086826@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 12 Dec 2016 11:11:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r309886 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Dec 2016 11:11:51 -0000 Author: kib Date: Mon Dec 12 11:11:50 2016 New Revision: 309886 URL: https://svnweb.freebsd.org/changeset/base/309886 Log: When a zombie gets reparented due to the parent exit, send SIGCHLD to the reaper. The traditional reaper init(8) is aware of zombies silently reparented to it after the parents exit, it loops around waitpid(2) to collect them. For other reapers, the silent reparenting is surprising and collecting zombies requires a thread blocking in waitpid(2) just for that purpose. It seems that sending second SIGCHLD is a better workaround than forcing all reapers to obey the setup. Reported by: Michael Zuo , jilles PR: 213928 Reviewed by: jilles (previous version) Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Modified: head/sys/kern/kern_exit.c Modified: head/sys/kern/kern_exit.c ============================================================================== --- head/sys/kern/kern_exit.c Mon Dec 12 11:04:22 2016 (r309885) +++ head/sys/kern/kern_exit.c Mon Dec 12 11:11:50 2016 (r309886) @@ -455,6 +455,11 @@ exit1(struct thread *td, int rval, int s if (!(q->p_flag & P_TRACED)) { proc_reparent(q, q->p_reaper); + if (q->p_state == PRS_ZOMBIE) { + PROC_LOCK(q->p_reaper); + pksignal(q->p_reaper, SIGCHLD, q->p_ksi); + PROC_UNLOCK(q->p_reaper); + } } else { /* * Traced processes are killed since their existence