From owner-freebsd-standards@FreeBSD.ORG Sat Mar 20 13:17:09 2004 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9094916A501; Sat, 20 Mar 2004 13:17:07 -0800 (PST) Received: from smtp2.server.rpi.edu (smtp2.server.rpi.edu [128.113.2.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id D11EF43DD2; Sat, 20 Mar 2004 12:51:45 -0800 (PST) (envelope-from drosih@rpi.edu) Received: from [128.113.24.47] (gilead.netel.rpi.edu [128.113.24.47]) by smtp2.server.rpi.edu (8.12.8/8.12.8) with ESMTP id i2KKpWEw020752; Sat, 20 Mar 2004 15:51:32 -0500 Mime-Version: 1.0 X-Sender: drosih@mail.rpi.edu Message-Id: Date: Sat, 20 Mar 2004 15:51:31 -0500 To: freebsd-standards@FreeBSD.org From: Garance A Drosihn Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-Scanned-By: CanIt (www . canit . ca) cc: Alexey Dokuchaev Subject: PATCH for a more-POSIX `ps', and related adventures X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Mar 2004 21:17:12 -0000 [this is BCC'ed to -arch so more people have a chance to see it, but I expect most of the discussion to happen in freebsd-standards]. It started out that I just wanted to get rid of one message that `ps' writes to stderr in -current but not in -stable. "As long as I was there", I thought I'd add support for a comma-separated list of processes for `ps -p' (as described in SUSv3). Alexey Dokuchaev asked if this change got us much closer to POSIX/SUS. Now it did get us a *little* closer, but in re-reading SUSv3 I realized that I didn't get it (that one option) quite as close as I would like. So, "as long as I was there", I figured I should try to come a little closer. Now, after about 30 consecutive "as long as I was there" small projects, I have an update which: Changes -p so it accepts a list of process IDs, and -t so it accepts a list of terminal names (instead of only allowing a single value). Adds the -A option of SUSv3 (exactly the same as `-ax') Adds the `-G gidlist' and '-g pgidlist' options of SYSv3. (note that this replaced a null `-g' option...) Adds a `-R ruserlist' option, which is the same as what SYSv3 describes for `-u' (we already have a `-u'). Amazingly, none of solaris, linux, or irix seem to have any kind of `-R' option. Adds a `-s sidlist' option, which is not in SUSv3, but it is in solaris, linux, and irix -- and it's an option I have personally wished for on occasion... Allows the user to specify any of these "selector options" multiple times, and have it keep adding to that list instead of replacing values for that list. Better parsing of options. Better error messages for invalid values (IMO). Fixes interactions between all these "selector options", & our `-x' option (which is not mentioned in SUSv3). For the selector options, I tried to meet the description of: "If any are specified, the default list shall be ignored and ps shall select the processes represented by the inclusive OR of all the selection-criteria options." Applies all these selection criteria *before* sorting the list of processes we get from kvm_getprocs(), and before using the list to compute the sizes of the output fields. That does not get us matching POSIX/SUSv3, but it does get us a lot closer. There are a few questions/issues that came up for me while writing this, but I'll list those in separate messages. I'll also do a minimal update to the man page before commiting this. I wanted to do this without bloating up the size of `ps' by too much, and on i386 the executable has grown by --- 164 bytes! (0.6% increase)! [at this point I will do a touchdown-style victory dance, and spike my keyboard into the floor...] The update weighs in at almost 900 lines, and is available at: http://people.freebsd.org/~gad/ps-susv3.diff I certainly didn't intend to end up with that large of an update, but at this point I'm not going to go back and try to break it down into 30 separate updates of 50 lines each... Please look it over, try it out, and let me know if these options seem to work the way you'd expect them to, or if I have messed anything up. And please please PLEASE -- don't give me any more ideas of something *else* I could do "as long as I'm there"! -- Garance Alistair Drosehn = gad@gilead.netel.rpi.edu Senior Systems Programmer or gad@freebsd.org Rensselaer Polytechnic Institute or drosih@rpi.edu