News, tips, partners, and perspectives for the Oracle Solaris operating system

ps tip

Guest Author

I often use the ps -ef command when looking for a running process. However, sometimes I'm frustrated by the fact that ps truncates the the CMD output. As an example:

bleonard@opensolaris:~$ ps -ef | grep evolution-data
bleonard 15803 1 0 Sep 27 ? 0:00 /usr/lib/evolution-data-server-1.2/evolution-data-server-2.24 --oaf-activate-i

In a recent opensolaris-help forum post, Mike Meyer provided some undocumented BSD compatible options to get more details:

I habitually use "ps auxww" (note no "-" - bsd ps doesn't require it, and that triggers the BSD mode of /usr/bin/ps), which is all processes (ax) in a "user" (u) format. No w option truncates each line at 80 characters, one w option truncates each line at 132 characters, and two w options doesn't truncate it at all.

So, for my example:

bleonard@opensolaris:~$ ps auxww | grep evolution-data
bleonard 15803 0.0 0.22351610840 ? S Sep 27 0:00 /usr/lib/evolution-data-server-1.2/evolution-data-server-2.24 --oaf-activate-iid=OAFIID:GNOME_Evolution_DataServer_CalFactory:1.2 --oaf-ior-fd=28

Of course, as it was also pointed out, once you know the process id you can get the same argument information, in a more readable format using, the pargs command:

bleonard@opensolaris:~$ pargs 15803

/usr/lib/evolution-data-server-1.2/evolution-data-server-2.24 --oaf-activate-ii
argv[0]: /usr/lib/evolution-data-server-1.2/evolution-data-server-2.24
argv[1]: --oaf-activate-iid=OAFIID:GNOME_Evolution_DataServer_CalFactory:1.2
argv[2]: --oaf-ior-fd=28

Or, in single line as pointed out in the comments below:

bleonard@opensolaris:~$ pgrep evolution-data | xargs pargs 

/usr/lib/evolution-data-server-1.2/evolution-data-server-2.24 --oaf-activate-ii
argv[0]: /usr/lib/evolution-data-server-1.2/evolution-data-server-2.24
argv[1]: --oaf-activate-iid=OAFIID:GNOME_Evolution_DataServer_CalFactory:1.2
argv[2]: --oaf-ior-fd=28

Join the discussion

Comments ( 6 )
  • Shmerl Wednesday, September 29, 2010

    Thanks, this is very useful! I was always bugged by OpenSolaris ps truncating commands, and couldn't figure out how to disable it.

  • blah Thursday, September 30, 2010

    I do something similar almost every day:

    pgrep pattern | xargs pargs | less

  • W Brian Leonard Thursday, September 30, 2010

    @blah, cool, thanks! I updated the entry with your tip.

  • Andreas Thursday, September 30, 2010

    Hi Brian,

    A good tip, I'm using the pgrep/pargs combination a lot. If you replace "pargs" with "pfiles", you can also list all open files instead of arguments.



  • Konstantin Tuesday, November 2, 2010

    Your happiness is premature :(

    The only thing "ps XXX" does after detecting BSD mode - is just exec("/usr/ucb/ps",XXX). That is what you could always do by yourself.

    The real pain of having two distinct ps (/usr/bin/ps and /usr/ucb/ps) is that - 1st one allows versatile filtering of rows and columns but always truncates output, the 2nd one doesn't truncate output but has very limited filtering capabilities.

    When I 1st read Mike's post, I thought that he found a way to force /usr/bin/ps to NOT truncate output, but he didn't :(

  • Subhash Friday, January 7, 2011

    Well, the workaround is to enable suid, thus :

    chmod 4555 /usr/ucb/sparc\*/ps

    However : bear in mind that /usr/ucb/ps is no longer a privileged process; you can

    only peek at your own processes. Since /usr/ucb/ps needed to read random

    data from address spaces there was a risk of leakage and that is

    compounded with the risk of /usr/ucb/ps being set-uid root, So, use it with caution, perhaps ok in development, but not so in production.

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.