From owner-freebsd-bugs@FreeBSD.ORG Fri Oct 10 06:00:42 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 078C416A4B3 for ; Fri, 10 Oct 2003 06:00:42 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3E37544022 for ; Fri, 10 Oct 2003 06:00:37 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h9AD0bFY059006 for ; Fri, 10 Oct 2003 06:00:37 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h9AD0beN059004; Fri, 10 Oct 2003 06:00:37 -0700 (PDT) (envelope-from gnats) Resent-Date: Fri, 10 Oct 2003 06:00:37 -0700 (PDT) Resent-Message-Id: <200310101300.h9AD0beN059004@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Jilles Tjoelker Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C137516A4B3 for ; Fri, 10 Oct 2003 05:54:07 -0700 (PDT) Received: from hexagon.stack.nl (hexagon.stack.nl [131.155.140.144]) by mx1.FreeBSD.org (Postfix) with ESMTP id E35BE43FE1 for ; Fri, 10 Oct 2003 05:54:06 -0700 (PDT) (envelope-from jilles@stack.nl) Received: from turtle.stack.nl (turtle.stack.nl [2001:610:1108:5010:2e0:81ff:fe22:51d8]) by hexagon.stack.nl (Postfix) with ESMTP id EC7EF1C0F for ; Fri, 10 Oct 2003 14:54:05 +0200 (CEST) Received: by turtle.stack.nl (Postfix, from userid 1677) id DC33C1CC71; Fri, 10 Oct 2003 14:54:05 +0200 (CEST) Message-Id: <20031010125405.DC33C1CC71@turtle.stack.nl> Date: Fri, 10 Oct 2003 14:54:05 +0200 (CEST) From: Jilles Tjoelker To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/57833: PATCH: ps cannot change title for keywords that are aliases X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Jilles Tjoelker List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Oct 2003 13:00:42 -0000 >Number: 57833 >Category: bin >Synopsis: PATCH: ps cannot change title for keywords that are aliases >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Oct 10 06:00:36 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Jilles Tjoelker >Release: FreeBSD 5.1-CURRENT i386 >Organization: Eindhoven University of Technology >Environment: System: FreeBSD turtle.stack.nl 5.1-CURRENT FreeBSD 5.1-CURRENT #15: Thu Oct 9 11:43:55 CEST 2003 jilles@turtle.stack.nl:/usr/obj/usr/src/sys/TURTLE i386 (The world is a few days older than that.) >Description: Some keywords of the -o option of ps have aliases. Changing the header text for aliases (by adding =text after the keyword) does not work. An example is that stat is an alias for state. >How-To-Repeat: jilles@turtle /home/jilles$ ps -o stat=S -p $$ ps: stat: illegal keyword specification STAT Ss jilles@turtle /home/jilles$ ps -o state=S -p $$ S Ss (A useful special case is that setting all header texts to the empty string removes the header line altogether.) >Fix: I have a patch. This removes the possibility of aliases for multiple other keywords (e.g. an alias virt for pid,state,time,sl,re,pagein,vsz,rss,lim,tsiz,%cpu,%mem,command could make ps -o virt do the same as ps -v). These do not exist currently, though, and don't seem very useful to me. If it is required, the old parsefmt(v->alias, user); return NULL; code can be added instead of errx(1, "%s: keyword not found (alias)", p); The user argument to findvar() is no longer used. --- keyword.c.patch begins here --- --- /usr/src/bin/ps/keyword.c.orig Wed Aug 13 20:37:33 2003 +++ /usr/src/bin/ps/keyword.c Fri Oct 10 14:09:29 2003 @@ -296,6 +296,7 @@ VAR *v, key; char *hp; + (void)user; hp = strchr(p, '='); if (hp) *hp++ = '\0'; @@ -304,12 +305,11 @@ v = bsearch(&key, var, sizeof(var)/sizeof(VAR) - 1, sizeof(VAR), vcmp); if (v && v->alias) { - if (hp) { - warnx("%s: illegal keyword specification", p); - eval = 1; - } - parsefmt(v->alias, user); - return ((VAR *)NULL); + key.name = v->alias; + v = bsearch(&key, var, sizeof(var)/sizeof(VAR) - 1, + sizeof(VAR), vcmp); + if (v == NULL) + errx(1, "%s: keyword not found (alias)", p); } if (!v) { warnx("%s: keyword not found", p); --- keyword.c.patch ends here --- >Release-Note: >Audit-Trail: >Unformatted: