Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9D36737B401 for ; Sun, 2 Mar 2003 14:30:05 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9D8B343FBF for ; Sun, 2 Mar 2003 14:30:04 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id h22MU4NS070946 for ; Sun, 2 Mar 2003 14:30:04 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id h22MU4KO070945; Sun, 2 Mar 2003 14:30:04 -0800 (PST) Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AB66C37B406 for ; Sun, 2 Mar 2003 14:27:47 -0800 (PST) Received: from thor.piqnet.org (adsl-66-125-235-59.dsl.sntc01.pacbell.net [66.125.235.59]) by mx1.FreeBSD.org (Postfix) with ESMTP id ACCE243F85 for ; Sun, 2 Mar 2003 14:27:46 -0800 (PST) (envelope-from joelh@thor.piqnet.org) Received: from thor.piqnet.org (localhost [IPv6:::1]) by thor.piqnet.org (8.12.6/8.12.6) with ESMTP id h22MRkVi061342 for ; Sun, 2 Mar 2003 14:27:46 -0800 (PST) (envelope-from joelh@thor.piqnet.org) Received: (from joelh@localhost) by thor.piqnet.org (8.12.6/8.12.6/Submit) id h22MRjYU061341; Sun, 2 Mar 2003 14:27:45 -0800 (PST) Message-Id: <200303022227.h22MRjYU061341@thor.piqnet.org> Date: Sun, 2 Mar 2003 14:27:45 -0800 (PST) From: Joel Ray Holveck Reply-To: Joel Ray Holveck To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: ports/48852: sysutils/pstree can go into infinite loop for zombies [PATCH] Sender: owner-freebsd-ports-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 48852 >Category: ports >Synopsis: sysutils/pstree can go into infinite loop for zombies [PATCH] >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Mar 02 14:30:04 PST 2003 >Closed-Date: >Last-Modified: >Originator: Joel Ray Holveck >Release: FreeBSD 5.0-RELEASE i386 >Organization: >Environment: System: FreeBSD thor.piqnet.org 5.0-RELEASE FreeBSD 5.0-RELEASE #13: Sun Feb 9 17:11:33 PST 2003 root@thor.piqnet.org:/usr/local/src/freebsd/src/sys/i386/compile/THOR i386 pstree v2.17 >Description: Under FreeBSD 5.0, zombie processes are reported by ps with pid 0. Also, init and swapper have ppid 0. This leads to a cycle, and pstree is only designed to handle trees. >How-To-Repeat: thor$ perl -e 'fork() && sleep 100;' ^Z [1]+ Stopped perl -e 'fork() && sleep 100;' thor$ bg [1]+ perl -e 'fork() && sleep 100;' & thor$ ps ax | grep perl 0 p9 ZW 0:00.00 (perl) 33322 p9 S 0:00.02 perl -e fork() && sleep 100; 33374 p9 S+ 0:00.01 grep perl Note the zombie perl with pid 0. Now: thor$ pstree|more Watch the output for cycles. You can search for '00000' to find them easily. >Fix: I know that there's a patch mechanism in ports, but I'm not sure what the proper way to submit a patch for that is. So here's a patch to the pstree source. --- pstree.c.~1~ Mon Dec 17 04:18:02 2001 +++ pstree.c Sun Mar 2 14:15:11 2003 @@ -655,8 +655,9 @@ sprintf(nhead, "%s%s ", head, head[0] == '\0' ? "" : EXIST(P[idx].sister) ? C->bar : " "); - for (child = P[idx].child; EXIST(child); child = P[child].sister) - PrintTree(child, nhead); + if (P[idx].pid) + for (child = P[idx].child; EXIST(child); child = P[child].sister) + PrintTree(child, nhead); } void Usage(void) { >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports-bugs" in the body of the message