From owner-freebsd-standards@FreeBSD.ORG Tue Apr 20 19:07:24 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 9B20216A4CE for ; Tue, 20 Apr 2004 19:07:24 -0700 (PDT) Received: from sccrmhc13.comcast.net (sccrmhc13.comcast.net [204.127.202.64]) by mx1.FreeBSD.org (Postfix) with ESMTP id 52A8643D31 for ; Tue, 20 Apr 2004 19:07:24 -0700 (PDT) (envelope-from albert@users.sf.net) Received: from c-65-34-189-253.se.client2.attbi.com ([65.34.189.253]) by comcast.net (sccrmhc13) with SMTP id <2004042102072301600d2f25e>; Wed, 21 Apr 2004 02:07:23 +0000 From: Albert Cahalan To: Garance A Drosihn In-Reply-To: References: <019601c426b0$77dc91a0$7890a8c0@dyndns.org> Content-Type: text/plain Organization: Message-Id: <1082504719.3444.534.camel@cube> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.4 Date: 20 Apr 2004 19:45:20 -0400 Content-Transfer-Encoding: 7bit cc: freebsd-standards@freebsd.org cc: Albert Cahalan Subject: Re: ps enhencements (posix syntax, and more) 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: Wed, 21 Apr 2004 02:07:24 -0000 On Tue, 2004-04-20 at 13:58, Garance A Drosihn wrote: > At 10:21 AM +0200 4/20/04, Cyrille Lefevre wrote: > >I've finished to cleanup my code and to merge recent changes > >made by Garance. I've get rid of my -X feature for now, and > >replaced it with -q (posix mode) and -Q (sunos/tru64 compat > >mode, aka the return of -g which means -a w/o process group > >leaders, and sizes displayed in KGM format). Having a "-q" for posix mode is kind of pointless, no? The same goes for "-Q". > >the next step would have to merge NetBSD/OpenBSD full dynamic > >sizing of fields (to get rid of our current static sizing of most > >of the fields) as well as to integrate the NetBSD -k keyword. > > Yeah, I wanted to do more with dynamic sizing, but I have not > spent any time on it yet. I have been looking at -k, but I > wasn't sure how much it would increase the size of `ps'. DYNAMIC FIELD SIZES: There are different choices here. Some can hurt you. It is good to produce some output before all the process data has been read. Think about piped commands running on an SMP box. Also, though I know FreeBSD never has kernel bugs, suppose some dodgey hardware caused process table corruption. You might want to at least be able to produce partial output. I re-align columns as I can. If VSZ overflows while there is some room in the TTY column, the spaces get grabbed up in order to keep other columns aligned. This works well. THE -k OPTION: Let's accept the NetBSD direction. SIZE OF PS: If the size of ps is a problem (for a boot floppy???), you can simply create a special ps for that. In the Linux world there is a busybox program that, after looking at argv[0], can act as ps, gzip, tar, dd, cp... In case you need to write something, I have a minimal.c program that implements ps in 8 kB on i386 or 10 kB on ppc. It's been ported away from Linux /proc before, and it can work with several non-GNU C libraries. Here is the feature set you'd get if you ported it: $ ./minimal --help -C select by command name (minimal ps only accepts one) -p select by process ID (minimal ps only accepts one) -e all processes (same as ax) a all processes w/ tty, including other users x processes w/o controlling ttys -f full format -j,j job control format v virtual memory format -l,l long format u user-oriented format -o user-defined format (limited support, only "ps -o pid=") h no header -------- NOW QUOTING FROM THE PR --------- > (-K) don't show kernel thread (option taken from openbsd -k, > *not implemented yet*). Gee, how many do you have? If they are per-CPU threads all doing the same thing, then only display one of them when the "H" option isn't used. > -g pgidlist select processes by process group id(s). If the PGID list contains non-numeric entries, then you should parse it as a list of effective group names and IDs. > -o fmtlist similar to bsd -o fmtlist. I have an explicit-width syntax that you might like. It does the obvious thing with "ps -o pid,wchan:42,args". > -c omits the nice field and replaces the c field with the > class field (option taken from solaris). It should do a bit more than that. Pushing format specifiers starting from the rightmost one goes like this: //////////////////////////////////////////////////// if -c-option then push "pri" push "class" else if -l-option push "ni" push "opri" endif if -L-option and -f-option then push "nlwp" endif if (-l-option or -f-option) and not -c-option then push "c" endif ///////////////////////////////////////////////////// As you can see, had the "c" field been replaced with the "class" field, "nlwp" would end up on the wrong side. For editing oddball formats, this works pretty well: 1. delete %CPU, CPU, CP, C, and NI 2. replace PRI ("opri") with CLS PRI ("class,pri") > -x wide output format (option taken from hpux, similar to bsd -ww) It's more useful to take this as meaning "show args" and just use -ww for wide output. Adding this option will make transition to a mixed POSIX/BSD parser much more difficult, because you won't be able to fall back to a pure BSD parser when "ps -ax" is seen. > fname FNAME alias to ucomm [solaris] Yes, except that it's narrow. Make it 8 characters wide. > opri alias to pri [solaris] Nope. They go opposite directions. KEYWORD SOURCE RANGE intpri HP-UX 39..79 opri SunOS 39..79 pri Everybody 20..60 <-- funny direction priority Linux -20..20 psxpri Tru64 ?????? (direction?) I suspect Tru64 gets "pri" kind of wrong, and uses "psxpri" to implement "PRI". Note that the UNIX and POSIX spec only specifies when "PRI" should appear. There is no standard keyword for this. > osz alias to sz [solaris] I think not, else why would osz exist? I think one of these is in pages, and the other in kB. > size alias to sz [just for convenience] Nope. This is the size of your swappable image. That would be dirty pages in RAM plus pages in swap, plus anything else (page tables?) that you could swap out. Origins may involve Novell or SCO. > wname alias to mwchan [irix] I interpret related options as: nwchan hex address wname function name wchan as wname, or nwchan with -n option