Subject: Re: sysv ps(1) implementation [was: ps(1) sysv silliness]
To: Simon Burge <simonb@netbsd.org>
From: Andrew Brown <atatat@atatdot.net>
List: tech-userlevel
Date: 06/10/2000 16:58:55
>> About supporting both BSD and System V style options in a single
>> executable: please take into consideration that there are at least
>> three command line options (-e, -p, -u) whose use differs between
>> 'our' BSD implementation and System V.
>
>The options are currently handled by two different getopt loops, so this
>isn't a problem. FWIW, "aegjloptuU" appear in both...
seems to me that it doesn't need to be so. you ought to be able to
have one big getopt loop that handled all switched (unless there are
options that require args in one that conflict with non-argument
switches in the other (hmm...'u' comes to mind).
behavior=BSD;
while (ch = getopt(argc, argv, "...reallylonglist...")) {
switch (ch) {
case 'B': behavior=BSD; break;
case 'V': behavior=SYSV (or whatever); break;
...
}
if (behavior==SYSV) {
complain about various non-sysv options...
}
else {
complain about various non-bsd options...
}
do stuff
and i'm sure something could be worked out so that 'u' got handled
properly...perhaps by
char *foov[],*uarg=NULL;
int fooc;
foov=argv;
fooc=argc;
while (fooc) {
while (getopt(...)) {
switch (ch) {
case 'u': opt_u=1; uarg=optarg; break;
...
}
if (bsd and uarg) {
foov[0]=uarg;
foov[1]=NULL;
fooc=1;
}
}
do complaint checking
ps - can someone please explain to me why (a) /usr/ucb/ps under
solaris seems to run much more slowly (takes longer to run) and (b)
why "/usr/bin/ps -ef" prints the command line while "/usr/ucb/ps
auxww" prints the setproctitle() stuff?
--
|-----< "CODE WARRIOR" >-----|
codewarrior@daemon.org * "ah! i see you have the internet
twofsonet@graffiti.com (Andrew Brown) that goes *ping*!"
andrew@crossbar.com * "information is power -- share the wealth."