I_WANT_A_BROKEN_PS

Sat Jul 24 01:01:02 2004 I_WANT_A_BROKEN_PS
Posted by Tony Lawrence
Search Keys: shell

In the old days, a "ps -e" on Linux would get you something like this:


Hate these ads?




warning: `-' deprecated; use `ps e', not `ps -e'
  PID TTY STAT TIME COMMAND
..


To get that now, you need to use "oldps". The man page (which you can still see with "man oldps") warned:



      For now, ps will give you a warning if you use a `-' for a
       short  option,  but it will still work.  If you have shell
       scripts which use BSD-style arguments to ps, take heed  of
       the  warning  and fix them, or else your scripts will fail
       to function correctly at some point in the future.  If you
       want  to turn off the warnings, set the I_WANT_A_BROKEN_PS
       environment variable.


When I first saw this, it ticked me off. From time to time, I've even made comments like:








 Personally, I think bsd ps semantics are "broken", not the
 other way around. But if I were putting in such a flag,
 I'd call it "I_WANT_BSD_FLAGS".


Well, I was wrong. Albert Cahalan (see the end of "man ps") set me straight:


I think Michael K. Johnson named that option, not me,
but I support the naming and the code behind it.



If you set that option, you make ps violate the POSIX and
UNIX standards. The common "ps -ef" command will not work.
(this is an ISO, IEEE, Open Group, and ANSI standard)



According to the standards, "ps -aux" is parsed the same
way as "ps -a -u x", with "x" being a username!



People who want the BSD options get them by default anyway,
with less typing. Why type "ps -aux" when "ps aux" will work?
Besides, it's more portable to leave off the "-". You can
use "ps aux" on AIX or Tru64, along with "ps -ef", but you
can't use "ps -aux" on those systems at all.



I like using both BSD and UNIX syntax, sometimes together.
For example:


ad



ps f -ef
ps -C bash,xterm u


OK, I see the error of my ways. But.. the new ps doesn't seem to mind using "ps -e" at all. So the warning seems not to have come true, at least not yet.

Reading the newer "man ps", I found this :



       PS_PERSONALITY   Description
       ()                                                             ()



       none             "Do the right thing"
       aix              like AIX ps
       bsd              like FreeBSD ps
       compaq           like Digital Unix ps
       debian           like the old Debian ps
       digital          like Digital Unix ps
       gnu              like the old Debian ps
       hp               like HP-UX ps
       hpux             like HP-UX ps
       irix             like Irix ps
       linux            deviate from Unix98 for convenience only
       old              like the original Linux ps
       posix            standard
       sco              like SCO ps
       sgi              like Irix ps
       sun              like SunOS 4 ps
       sunos            like SunOS 4 ps
       sysv             standard
       unix             standard
       unix95           standard
       unix98           standard





That made me think that if I set PS_PERSONALITY to "old" (and exported it) that "ps -e" would act like "oldps -e", but it doesn't (at least not on the system I tried it on). However, setting and exporting CMD_ENV did alter the behaviour as expected, though you don't get the "deprecated" message.

It's fun to play with the various settings. I notice that "sco" is one of the options, though I'm not sure what effects that has. Perhaps it causes "ps" to spawn a lawsuit?

See How "ps" works and why also.



Comments /Blog/B1011.html
CommentsBlog1011 :

"I notice that 'sco' is one of the options, though I'm not sure what effects that has. Perhaps it causes "ps" to spawn a lawsuit?"

That happens only if the DARL_MCBRIDE environment variable has been set.

Regarding the ps semantics, I really don't appreciate some of these ADD-suffering coders intentionally deviating from the POSIX standards so as avoid typing one or two extra characters. I have enough trouble keeping all this stuff straight in my head without someone arbitrarily adding to the confusion. Let's try to maintain syntactical uniformity, even if it means typing that dreaded minus sign.

--BigDumbDinosaur

---July 24, 2004


I've been told that "oldps" no longer exists (I was using an older RedHat server) and that PS_PERSONALITY now works just as CMD_ENV did here.

The problem with the "-" stuff is this: BSD never required a "-", and unfortunately some of their option letters have different meanings. So how should "ps -e" be interpreted? Should it show the environment or every process? Setting PS_PERSONALITY lets you force that decision, otherwise the new "ps" tries hard to "do the right thing". Albert has sent me some longer explanations of this which I have asked permisson to publish.


--TonyLawrence





Add your comments

Enter your email address for automatic notification of new posts here
(be sure to whitelist 'feedburner.com' if you use spam filtering)

Or use any RSS reader

Delivered by FeedBurner


M3IP inc.

Views for this page
Today This Week This Month This Year  Overall
11567519 5,601

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here

pavatar.jpg
More:
       - Linux
       - Unix
       - Blog




Related Posts

100% CPU Load

Why is my system so slow?

How "ps" works and why


Unix/Linux Consultants

Your ad here - $24.00 yearly!

http://echo3.net/ Unix/Linux Custom Applications, Web Hosting, C/C++ Programming Courses


http://www.m3ipinc.com Security, firewalls, ids, audits, vulnerability assesments, BS7799, HIPAA, GLB, incident handling


http://www.cleverminds.net Need expert advice? Want a second opinion? CleverMinds is a one-stop-shop for a wide range of technology solutions. We support Unix, Linux, SCO as well as CMS, ecom, blogs, podcasts, search engines consulting and more. Contact us at web2.0@cleverminds.net 0r (617) 894-1282




card_image








Change Congress


Related Posts