X

Casper Dik's Weblog

Solaris 11.3 SRU 5.6: updates in ps(1) and /proc/<pid>/{cmdline,environ,execname}

Casper Dik
Senior Principal Software Engineer

Almost as soon as Solaris 2.0 was released, people started to complain about the limit of the ps(1) command line output; it was limited to 80 characters. The standard ps(1) command was also not able to print the environment variables.

The /usr/ucb/ps command could, but it needed to trawl through the address space of the target process.  In order to do so it needs to have at least the same privileges and uids/gids to prevent privilege escalation.  Simple having the {proc_owner} privilege is not sufficient.

When we added pkill(1)/pgrep(1), they to were limited in the same way: they could only find search the first 80 bytes of the command line (PRARGSZ) and the first 16 bytes of the command name (PRFNSZ).

 These were serious limitation; for one, it became difficult to find a specific java process as the typical java command line is generally much larger than 80 bytes and the often the important jar file is beyond the 80 byte limit.

 Of course, our customers did not like this limit either.

 We fixed this problem in Solaris 12 and now also in Solaris 11.3 SRU 5.6 by adding three new files under /proc/<pid>:

  • cmdline - all original arguments separated by NUL bytes
  • environ -  all original environment values separated by NUL bytes
  • execname - the original program name given to exec.

The cmdline and execname are publicly readable; the environ file is restricted to the owner of the process or those processes which have the {proc_owner} privilege. The cmdline and environment file are very similar to those found under Linux, however these do reflect the actual argument vectors in the process' address space, so they do not reflect the changes made by the programs themselves.

A new -o format option "env" was added to ps(1); the new files are used and ps(1) will now display the full command line.

 As neither ps(1) or ps(1b) needs to open /proc/<pid>/as, fewer privileges are now needed and read access to he executable is no longer required: this is big performance win for ps(1b) especially when NFS binaries are in the mix.

As I basically back ported changes to ps and /proc from Solaris 12, the whole list bugs and enhancement is as follows:

        PSARC/2015/207 /proc/<pid>/{cmdline,environ,execname} extensions to /proc.
        15742822 SUNBT7092685 Extend /proc interfaces to allow ps(1) to show more of the command
        15420404 SUNBT6599384 pgrep/pkill don't find processes with 16 char filenames or match ...
        19669195 memory-leak in ucb_procinfo of ucbps.c:569
        15227016 SUNBT5100626 ps(1) sometimes shows an empty string for the ttyname
        15282779 SUNBT6313436 /usr/ucb/ps malloc() failure results in unexpected argument parsing
        14966583 SUNBT4157509 /usr/ucb/ps not bsd or sunos 4.x compatible on command line
        15488063 SUNBT6715628 ps -d makes -z have no effect
        21447952 /usr/ucb/ps gxw hangs, but w/out the w does not; never open /proc/<pid>/as
        21297345 procfs limits the size of the control messages
        15582848 SUNBT6872216 ps command needs to keep trackof prior name/uid information
        15584899 SUNBT6875625 ps command should chdir to /proc to remove lock contention




Join the discussion

Comments ( 3 )
  • Former Sun Employee Monday, February 22, 2016

    So Casper when do you back-port this to Solaris 10 1/13 via the next 10_Recommended patch set ;)


  • Casper Dik Tuesday, February 23, 2016

    Yeah, it is in the queue behind Solaris 10 support for guest only kernel-zone

    support :-)

    Seriously, get on with the program. One comment we got from customers when

    they finally went to Solaris 11 was "Why didn't you force us

    earlier?"

    It is so much easier to maintain and much more modern. Perhaps you have some

    of our old hardware and it doesn't want to die but won't work under Solaris 11?

    Or because there is no upgrade path?


  • Former Sun Employee Tuesday, February 23, 2016

    "Seriously, get on with the program."

    We still have some hardware doing specific tasks that run perfectly fine which can't run Solaris 11. (A few SunFire V240s and even an old Sun Blade 150.)

    But mostly we support things called "Spacecraft flight projects" that have frozen configurations and are only funded through 2017, so there is no funding, popular support or incentive for us to move forward under these constraints on the platforms (T5120/T5140/T4-1) we do have which can support Solaris 11.

    Plus, it doesn't run on my home Sun Blade 2500 ;)

    (One thing I learned at Sun: the customers will always come up with some usage or configuration that you don't envision, and have a perfectly good reason for doing so.)


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

Integrated Cloud Applications & Platform Services