posix ps (was Re: Adding `pgrep' and `pkill' to /usr/bin)

Cyrille Lefevre root at gits.dyndns.org
Fri Mar 26 14:51:31 PST 2004


"Albert Cahalan" <albert at users.sourceforge.net> wrote:

> Cyrille Lefevre writes:
>
> > two years ago, I've added posix syntax and so to my locally ps(1).
> > for instance, I'm currently adding the notion of dynamic personalities
>
> OK, would YOU be interested in working with me on some sort of
> common ps specification beyond what SUSv3 has to offer? I'd love
> to see something that Sun could adopt, and that could be mostly
> merged into the next revision of the standard.

why not :)

> > (the term comes from linux) instead of static #define such as... say :
> >
> > $ ps -X help
> > any bsd bsd43reno bsd44 default extended freebsd hpux irix netbsd none
openbsd
> > pedantic posix relaxed solaris sunos susv3 tru64
>
> So you use "-X" as an escape into long options? Why not "--help"?

no, PERSONALITY=solaris is the same as -X solaris. -X is the option
I use to switch between personalities. so, -X help is a sort of -L which
lists available keywords. -o help in the posix syntax stands for -L in
the bsd syntax. I don't use -L as in the bsd syntax to avoid a
conflict with -L which permit to list threads in the solaris syntax.

> > personalities enable options such as :
> > bsd ps :
> >     -g and -n from sunos, -s from tru64 and some other options.
> > posix ps : see susv3 man (see
> > http://www.opengroup.org/onlinepubs/007904975/toc.htm)
> >     -j from all except posix
> >     -c, -y and -P from solaris
> >     -C cmdlist (ala pgrep :) and -x from hpux
>
> That "-x" will hurt you. Without it, it is easy for a SUSv3 parser
> to detect the common old "ps -ax" syntax.

well, hpux -f only list the first 64 characters of a command line
(where solaris list the first 80 ones), the hpux -x option is
equivalent to the bsd -ww option.

> BTW, I have a regression test suite that you might find useful.

yes, of course. for instance, I'm trying to resolve header's naming,
say user is USER or UID depending of the personality... etc.

> >     -M from irix
>
> Do you have documentation or examples for this?

irix -M is freebsd -Z, so, simple to implement :)

> >     and some others
> > they also enable many keywords such as :
> >     RUSAGE and co from tru64, class and psr from solaris, and many others
> > (mostly aliases)
> >
> > when finished, I'll probably submit these changes as a port in the meantime
> > since I suppose -arch will reject these important changes to a native
command.
> > the most important and not done part is... the manual page. any volonteers ?
>
> Step 1:
>
> a. ps does old BSD behavior by default

true

> b. /posix/bin/ps is a script that sets the SUSv3 personality
> c. /usr/ucb/ps is a link to /bin/ps

no problem.

> Step 2:
>
> a. ps does SUSv3 by default
> b. /posix/bin/ps is a link to /bin/ps
> c. /usr/ucb/ps is a script that sets the old BSD personality
>
> > $ PERSONALITY=susv3,+extended ps -?
> > usage: ps [-AacdefjlPxy] [-C cmdlist] [-G grouplist] [-g pgrplist]
> >           [-n system [-n core]] [-O fmtlist] [-o fmtlist] [-p pidlist]
> >           [-s sidlist] [-t ttylist] [-U ruserlist] [-u userlist] [-X
perslist]
> >        ps -o help
> >        ps -X help
>
> What syntax do you use for PERSONALITY settings? Let's do
> something compatible.

[=+-]keyword[,[=+-]keyword ...]

"=" is optional and say "this personality", "+" say add "this personality"
to the previous one, and "-" say delete "this personality" to the previous one.

possible personalities by themself are :
bsd43reno bsd44 default freebsd hpux irix netbsd openbsd solaris sunos susv3
tru64
any : all above
none : none of the above

possible switches
bsd : bsd syntax
extended : allow enhanced options and keywords.
pedantic : be strict about the syntax (-p pid instead of -p pidlist)
posix : posix syntax (! bsd)
relaxed : ! pedantic

some examples :

tru64,-posix is equivalent to tru64,+bsd since tru64 implies +posix

freebsd,-pedantic,+extended allow -p pidlist, -g and -n sunos options
and -s tru64 options.

susv3,+extended is strictly posix but allow the following options :
-C cmdlist hpux : select processes by name
-c irix/hpux/solaris : omit c and nice column, add cls column
-j irix/hpux/solaris/tru64 : job control informations
-O fmtlist bsd/tru64 : pid fmtlist s tty time comm
-P hpux/solaris : add psr column
-s sidlist irix/hpux/solaris/tru64 : select process by session id
-x hpux : equivalent to -ww bsd option
-y solaris : omit f and addr columns, add rss column

> The name isn't so good. Tru64 uses CMD_ENV for this, affecting
> more than just ps. I made PS_PERSONALITY take priority so that
> you could change ps behavior without changing other behaviors.

PS_PERSONALITY is the name that linux uses. this may conflict in
.profiles since the syntax is different. to complete what you say :
irix uses _XPG=1 and hpux uses UNIX95=1
of course, all of them could be tested for more and more compatobility :)

> You forgot the "-F" from DYNIX/ptx. It's really nice.

any pointer ?

Cyrille Lefevre.
-- 
home: mailto:cyrille.lefevre at laposte.net



More information about the freebsd-arch mailing list