From owner-freebsd-threads@FreeBSD.ORG Fri Jul 12 18:50:01 2013 Return-Path: Delivered-To: freebsd-threads@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 880248EB for ; Fri, 12 Jul 2013 18:50:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id 79C5F189D for ; Fri, 12 Jul 2013 18:50:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.7/8.14.7) with ESMTP id r6CIo12R072154 for ; Fri, 12 Jul 2013 18:50:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.7/8.14.7/Submit) id r6CIo1Hw072153; Fri, 12 Jul 2013 18:50:01 GMT (envelope-from gnats) Date: Fri, 12 Jul 2013 18:50:01 GMT Message-Id: <201307121850.r6CIo1Hw072153@freefall.freebsd.org> To: freebsd-threads@FreeBSD.org Cc: From: Konstantin Belousov Subject: Re: threads/180496: clock_gettime() does not return CPU-time for zombie processes X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Konstantin Belousov List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Jul 2013 18:50:01 -0000 The following reply was made to PR threads/180496; it has been noted by GNATS. From: Konstantin Belousov To: Petr Salinger Cc: freebsd-gnats-submit@FreeBSD.org Subject: Re: threads/180496: clock_gettime() does not return CPU-time for zombie processes Date: Fri, 12 Jul 2013 21:47:43 +0300 Please try this. The clock_gettime() call on zombie clock worked for me. Note that the check for clock_getres() on the reapped process clock failed since we do not check for pid validity, all processes has the same clock. I do not see much sense in adding the useless check. diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index b68c949..9e0cc06 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -297,14 +297,9 @@ get_cputime(struct thread *td, clockid_t clock_id, struct timespec *ats) PROC_UNLOCK(td2->td_proc); } else { pid = clock_id & CPUCLOCK_ID_MASK; - p2 = pfind(pid); - if (p2 == NULL) - return (EINVAL); - error = p_cansee(td, p2); - if (error) { - PROC_UNLOCK(p2); + error = pget(pid, PGET_CANSEE, &p2); + if (error != 0) return (EINVAL); - } get_process_cputime(p2, ats); PROC_UNLOCK(p2); }