Date: Thu, 26 Sep 2002 13:47:10 +0100 (IST) From: James Raftery <james@now.ie> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/43389: [PATCH] ps(1) prints blank line if no headers specified Message-ID: <200209261247.g8QClAG71375@bender.kerna.ie>
next in thread | raw e-mail | index | archive | help
>Number: 43389
>Category: bin
>Synopsis: [PATCH] ps(1) prints blank line if no headers specified
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Thu Sep 26 05:50:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: James Raftery
>Release: FreeBSD 4.5-RELEASE-p18 i386
>Organization:
<None>
>Environment:
System: FreeBSD bender.kerna.ie 4.5-RELEASE-p18 FreeBSD 4.5-RELEASE-p18 #2: Wed Aug 7 10:16:16 IST 2002 root@bender.kerna.ie:/usr/obj/usr/src/sys/BENDER i386
>Description:
ps(1) prints a blank line when no column headers are specified.
>How-To-Repeat:
With headers:
ocelot:lecter$ ps -o pid=p -o cpu=c -p 1
p c
1 0
ocelot:lecter$
Without headers:
ocelot:lecter$ ps -o pid= -o cpu= -p 1
1 0
ocelot:lecter$
>Fix:
Patch below which scans the header list and stops
printheader() if there are no headers to print.
#
# Verified to apply to:
# /usr/src/bin/ps/print.c revisions 1.36.2.2 and 1.36.2.3
#
# This patch stops ps(1) from printing a blank line when no/empty
# headers are specified. Apply the patch, then 'make all install' in
# /usr/src/bin/ps.
#
# James Raftery <james@now.ie>
#
--- print.c.orig Thu Sep 26 11:35:36 2002
+++ print.c Thu Sep 26 12:56:42 2002
@@ -67,6 +67,16 @@
{
VAR *v;
struct varent *vent;
+ int i;
+
+ for (vent = vhead; vent; vent = vent->next) {
+ v = vent->var;
+ if (strlen(v->header) > 0)
+ i = 1;
+ }
+
+ if (i != 1)
+ return;
for (vent = vhead; vent; vent = vent->next) {
v = vent->var;
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200209261247.g8QClAG71375>
