man ps: OSX strikes back.

It seems that man pages on OSX are misaligned with the commands sometime.

Example:

From
$ man ps

I read:

  -e      Identical to -A.

But look how identical they are:

luigi@noname:~$ ps -e
  PID   TT  STAT      TIME COMMAND
12332 s000  S+     0:00.03 -bash PATH=/usr/bin:/bin:/usr/sbin:/sbin TMPDIR=/var/folders/+K
12376 s001  R      0:00.03 -bash PATH=/usr/bin:/bin:/usr/sbin:/sbin TMPDIR=/var/folders/+K
luigi@noname:~$ ps -A
  PID   TT  STAT      TIME COMMAND
    1   ??  Ss     0:02.20 /sbin/launchd
   10   ??  Ss     0:06.80 /usr/libexec/kextd
   11   ??  Ss     0:05.26 /usr/sbin/notifyd
   13   ??  Ss     0:12.82 /usr/sbin/ntpd -c /private/etc/ntp-restrict.conf -n -g -p /var/
   14   ??  Ss     4:17.86 /usr/sbin/update
   15   ??  Ss     0:00.01 /sbin/SystemStarter
   17   ??  Ss     0:02.47 /usr/sbin/syslogd
   19   ??  Ss     0:01.87 /usr/sbin/securityd -i
   21   ??  Ss     2:50.52 /System/Library/Frameworks/CoreServices.framework/Frameworks/Me
   22   ??  Ss     0:16.24 /usr/sbin/mDNSResponder -launchd
   23   ??  Ss     6:19.50 /System/Library/CoreServices/loginwindow.app/Contents/MacOS/log
   24   ??  Ss     0:00.02 /usr/sbin/KernelEventAgent
   26   ??  Ss     9:14.55 /usr/libexec/hidd
   27   ??  Ss     0:24.74 /System/Library/Frameworks/CoreServices.framework/Versions/A/Fr
   29   ??  Ss     0:00.00 /sbin/dynamic_pager -F /private/var/vm/swapfile
   32   ??  Ss     0:03.85 /usr/sbin/diskarbitrationd
   33   ??  Ss     0:24.93 /usr/sbin/DirectoryService
   35   ??  Ss     0:35.43 /usr/sbin/configd
   38   ??  Ss     0:00.13 autofsd
   39   ??  Ss     0:03.07 /usr/libexec/ApplicationFirewall/socketfilterfw
   40   ??  Ss     0:00.02 /Library/Application Support/iStat menus/iStatMenusProcessServe
   41   ??  Ss     0:08.00 /usr/sbin/distnoted
   44   ??  Ss     0:32.01 /System/Library/CoreServices/coreservicesd
   46   ??  Ss     0:03.18 /usr/sbin/blued
  104   ??  Ss    90:40.66 /System/Library/Frameworks/ApplicationServices.framework/Framew
  138   ??  Ss     0:02.60 /sbin/launchd
  142   ??  S      0:00.63 /System/Library/CoreServices/AirPort Base Station Agent.app/Con
  146   ??  S      0:06.82 /System/Library/CoreServices/Spotlight.app/Contents/MacOS/Spotl
  147   ??  S      0:00.87 /usr/sbin/UserEventAgent -l Aqua
  149   ??  Ss     0:06.15 /usr/sbin/coreaudiod
  150   ??  S      0:53.94 /System/Library/CoreServices/Dock.app/Contents/MacOS/Dock -psn_
  152   ??  U     40:44.63 /System/Library/CoreServices/SystemUIServer.app/Contents/MacOS/
  153   ??  S      4:51.92 /System/Library/CoreServices/Finder.app/Contents/MacOS/Finder -
  154   ??  S      0:47.90 /System/Library/Frameworks/ApplicationServices.framework/Framew
  155   ??  S      0:00.00 /usr/sbin/pboard
  165   ??  S      0:00.39 /Users/luigi/Library/Application Support/iStat menus/Helpers/iS
  168   ??  S      0:03.39 /System/Library/Frameworks/InstantMessage.framework/iChatAgent.
  360   ??  S      0:00.19 /System/Library/Services/AppleSpell.service/Contents/MacOS/Appl
 1265   ??  S      0:00.02 /usr/bin/ssh-agent -l
 2711   ??  U      8:18.73 /Applications/Path Finder.app/Contents/MacOS/Path Finder -psn_0
 9364   ??  S      0:00.20 /Applications/iTunes.app/Contents/Resources/iTunesHelper.app/Co
 9366   ??  Ss     0:00.01 /System/Library/PrivateFrameworks/MobileDevice.framework/Versio
12279   ??  SNs    0:01.16 /System/Library/Frameworks/CoreServices.framework/Frameworks/Me
12302   ??  S      3:42.39 /Applications/Firefox.app/Contents/MacOS/firefox-bin -psn_0_747
12315   ??  Ss     0:00.52 /System/Library/Frameworks/ApplicationServices.framework/Framew
12330   ??  S      0:17.35 /Applications/iTerm.app/Contents/MacOS/iTerm -psn_0_7513898
12352   ??  S      0:02.56 /Applications/VirtualBox.app/Contents/MacOS/VBoxSVC --pipe 8 --
12353   ??  S      0:00.36 /Applications/VirtualBox.app/Contents/MacOS/VBoxXPCOMIPCD
12373   ??  S      0:02.01 /Applications/VirtualBox.app/Contents/MacOS/VirtualBox -psn_0_7
12476   ??  S      0:08.90 /Applications/Preview.app/Contents/MacOS/Preview -psn_0_7583547
12331 s000  Ss     0:00.02 login -fp luigi
12332 s000  S+     0:00.03 -bash
12375 s001  Ss     0:00.01 login -fp luigi
12376 s001  S      0:00.03 -bash
12530 s001  R+     0:00.00 ps -A

Always from "man ps" I read:

     -f      Display the uid, pid, parent pid, recent CPU usage, process start time, controling tty,
             elapsed CPU usage, and the associated command.  If the -u option is also used, display
             the user name rather then the numeric uid.  When -o or -O is used to add to the display
             following -f, the command field is not truncated as severely as it is in other formats.

Look how nice this option works:

luigi@noname:~$ ps -f
ps: illegal option -- f
usage: ps [-AaCcEefhjlMmrSTvwXx] [-O fmt | -o fmt] [-G gid[,gid...]]
          [-u]
          [-p pid[,pid...]] [-t tty[,tty...]] [-U user[,user...]]
       ps [-L]

I noticed that those two options are not working because usually to check the PID of a process on linux I use the command "ps -ef". Both -e and -f don't work as expected on OSX. 100% failure.

Now I wonder where I have to read to know how the damn ps works on OSX.

Apple, next time, use Linux as base for your OS. At least man pages will reflect the commands. OSX really sucks.
I'm praying that Ubuntu will soon have a good hardware support for my macbook.


7 Responses to “man ps: OSX strikes back.”  

  1. 1 James Sadler

    You can fix the ps -ef (illegal option) problem by ensuring that the environment variable COMMAND_MODE is set to unix2003

    I have found that launching ps via iTerm would exhibit the problem but not when run via Terminal.app.

    Set the environment variable in your bashrc or profile (or better yet, in the system-wide version in /etc).

    I can’t help you with the man page inconsistencies, although it may be that the man pages are documenting the unix2003 behaviour, and all might be consistent when you try running those commands again with unix2003

    Hope that helps.

  2. 2 Luigi

    Thanks James!

  3. 3 Pavel

    Wow! It works for me too! Thanks to Luigi (for raising the question) and to James (for answering it)!

  4. 4 Mike P

    Dude I love you guys! Thank you so much for figuring this out James I was cursing Apple like crazy for this :)

  5. 5 BoeroBoy

    I’m having the same headaches here. ps isn’t the only inconsistency in OSX. Maybe this is partly why Apple is discontinuing it.

    The man page also speaks of -u for showing user name instead of the much more useless user id. -u doesn’t work with ps on OSX, even when COMMAND_MODE=unix2003. And it seems there’s no way to show user name with ps in OSX …?

    Our sys builders should have gone with Linux or waited another year until Apple discontinued the XServe.

  6. 6 alex fairchild

    Da Man == James

    thank you so much!

  7. 7 Simon

    For printing a user name this works for me:

    ps -axj -o”user”

    Simon.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>



Calendar

March 2009
M T W T F S S
« Feb   Apr »
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Follow me

twitter flickr LinkedIn feed

Subscribe by email

Enter your email address:

Archives


Categories

Tag Cloud


Listening