Date: Sun, 2 Mar 2003 14:27:45 -0800 (PST) From: Joel Ray Holveck <joelh@piqnet.org> To: FreeBSD-gnats-submit@FreeBSD.org Subject: ports/48852: sysutils/pstree can go into infinite loop for zombies [PATCH] Message-ID: <200303022227.h22MRjYU061341@thor.piqnet.org>
next in thread | raw e-mail | index | archive | help
>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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200303022227.h22MRjYU061341>