Subject: ps(1) sysv silliness
To: None <tech-userlevel@netbsd.org>
From: Simon Burge <simonb@netbsd.org>
List: tech-userlevel
Date: 06/08/2000 09:47:58
Folks,

I've got some relatively simple mods to ps(1) so that it uses SysV-type
command-line argument parsing instead of the traditional BSD-style
parsing if a certain environment variable is set (I chose PS_SYSV but
Luke suggested that there might be a `global' "use-sysv-arguments"
variable that other programs could recognise as well).

Here's a sample:

	wincen:src/bin/ps 258> env PS_SYSV=1 ./obj.i386/ps -ef
	USER    PID PPID CPU STARTED TT   TIME COMMAND
	simonb  204  203   0 Wed08AM p0 0:01.11 -tcsh 
	simonb 1070  204   0  3:09PM p0 0:03.31 vi ps.c 
	simonb 1245 1244   4  7:44PM p1 0:00.28 -tcsh 
	root    180    1   0 Wed08AM ?? 0:04.95 /usr/sbin/ntpd 
	simonb 1603  204   1  9:41AM p0 0:00.01 ./obj.i386/ps -ef 
	root      1    0  22 Wed08AM ?? 0:00.01 init 
	root     98    1   0 Wed08AM ?? 0:00.02 /usr/sbin/rpcbind -l 
	root    197    1   0 Wed08AM ?? 0:00.44 /usr/sbin/cron 
	root     86    1   0 Wed08AM ?? 0:00.36 /usr/sbin/syslogd -s 
	root    203  192   0 Wed08AM ?? 0:02.40 rlogind 
	root   1244  192   0  7:44PM ?? 0:00.08 rlogind 
	root    192    1   0 Wed08AM ?? 0:00.02 /usr/sbin/inetd -l 
	root    241    1   0 Wed08AM ?? 0:00.16 /usr/libexec/getty Pc ttyE0 
	root    199    1   0 Wed08AM 00 0:00.01 /usr/libexec/getty std.9600 tty00 
	root    243    1   0 Wed08AM E2 0:00.03 /usr/libexec/getty Pc ttyE2 
	root    244    1   0 Wed08AM E3 0:00.03 /usr/libexec/getty Pc ttyE3 
	root    242    1   0 Wed08AM E1 0:00.02 /usr/libexec/getty Pc ttyE1 
	root      0    0   0 Wed08AM ?? 0:00.11 (swapper)
	root     46    0   0 Wed08AM ?? 0:00.00 (nfsio)
	root     45    0   0 Wed08AM ?? 0:00.00 (nfsio)
	root     44    0   0 Wed08AM ?? 0:00.00 (nfsio)
	root     43    0   0 Wed08AM ?? 0:00.01 (nfsio)
	root     42    0   0 Wed08AM ?? 0:00.02 (nfsio)
	root     41    0   0 Wed08AM ?? 0:00.05 (nfsio)
	root      4    0   0 Wed08AM ?? 0:02.61 (ioflush)
	root      3    0   0 Wed08AM ?? 0:00.11 (reaper)
	root      2    0   0 Wed08AM ?? 0:00.01 (pagedaemon)

	wincen:src/bin/ps 259> env PS_SYSV=1 ./obj.i386/ps -df
	USER    PID PPID CPU STARTED TT   TIME COMMAND
	simonb 1070  204   0  3:09PM p0 0:03.31 vi ps.c 
	simonb 1604  204   0  9:41AM p0 0:00.00 ./obj.i386/ps -df 
	root    203  192   0 Wed08AM ?? 0:02.40 rlogind 
	root   1244  192   0  7:44PM ?? 0:00.08 rlogind 
	root    241    1   0 Wed08AM ?? 0:00.16 /usr/libexec/getty Pc ttyE0 
	root     46    0   0 Wed08AM ?? 0:00.00 (nfsio)
	root     45    0   0 Wed08AM ?? 0:00.00 (nfsio)
	root     44    0   0 Wed08AM ?? 0:00.00 (nfsio)
	root     43    0   0 Wed08AM ?? 0:00.01 (nfsio)
	root     42    0   0 Wed08AM ?? 0:00.02 (nfsio)
	root     41    0   0 Wed08AM ?? 0:00.05 (nfsio)
	root      4    0   0 Wed08AM ?? 0:02.61 (ioflush)
	root      3    0   0 Wed08AM ?? 0:00.11 (reaper)
	root      2    0   0 Wed08AM ?? 0:00.01 (pagedaemon)

	wincen:src/bin/ps 260> env PS_SYSV=1 ./obj.i386/ps -af
	USER    PID PPID CPU STARTED TT   TIME COMMAND
	simonb  204  203   0 Wed08AM p0 0:01.11 -tcsh 
	simonb 1070  204   0  3:09PM p0 0:03.31 vi ps.c 
	simonb 1245 1244   4  7:44PM p1 0:00.28 -tcsh 
	simonb 1605  204   0  9:41AM p0 0:00.00 ./obj.i386/ps -af 
	root    199    1   0 Wed08AM 00 0:00.01 /usr/libexec/getty std.9600 tty00 
	root    243    1   0 Wed08AM E2 0:00.03 /usr/libexec/getty Pc ttyE2 
	root    244    1   0 Wed08AM E3 0:00.03 /usr/libexec/getty Pc ttyE3 
	root    242    1   0 Wed08AM E1 0:00.02 /usr/libexec/getty Pc ttyE1 

	wincen:src/bin/ps 261> env PS_SYSV=1 ./obj.i386/ps -f -u simonb
	USER    PID PPID CPU STARTED TT   TIME COMMAND
	simonb  204  203   0 Wed08AM p0 0:01.11 -tcsh 
	simonb 1070  204   0  3:09PM p0 0:03.31 vi ps.c 
	simonb 1245 1244   4  7:44PM p1 0:00.28 -tcsh 
	simonb 1606  204   0  9:43AM p0 0:00.01 ./obj.i386/ps -f -u simonb 

Is this:

 a) So pukable that noone in their right mind would ever use it?
 b) Useful so we can tick another SVID-type standards box?

Comments, criticisms and even flames accepted on this one :)

Simon.