Solaris proc commands

In Solaris, every object is either a file or a process. With the introduction of the /proc structure, there has been an effort to represent even processes as files.

The /proc directory also known as the process file system (procfs) is a virtual file system that allows us to examine processes like regular files. /proc does not occupy disk space; it is located in working memory.

Under /proc is a list of numbers, each of which is a Process ID (PID) for a process on the system. Under these directories are subdirectories referring to the different components of interest of each process. This directory structure can be examined directly, but we usually prefer to use commands written to extract information from this structure. These are known as the p-commands.

The proc tools (p-commands)

The p-commands (proc tools) are useful for tracing attributes of processes. These utilities include:

p-commandDescription
pcred Display process credentials (eg EUID/EGID, RUID/RGID, saved UIDs/GIDs)
/usr/bin/pcred pid
/usr/bin/pcred [-u <user>/<uid>] [-g <group>/<gid>] [-G <grouplist>] pid
/usr/bin/pcred -l <login> pid
pfiles Reports fstat() and fcntl() information for all open files. This includes information on the inode number, file system, ownership and size.
/usr/bin/pfiles [-Fn] pid...
pflags Prints the /proc tracing flags, the pending and held signals and other /proc status information for each LWP in each process.
/usr/bin/pflags [-r] [pid | core]
pgrep Finds processes matching certain criteria.
pkill Kills specified processes.
pldd Lists dynamic libraries linked to the process, including shared objects explicitly attached using dlopen.
/usr/bin/pldd [-F] [pid | core]
pmap Prints the address space map of each process.
/usr/bin/pmap [-rslF] [pid | core]
/usr/bin/pmap -x [-aslF] [pid | core]
/usr/bin/pmap -S [-alF] [pid | core
prun Starts stopped processes.
/usr/bin/prun pid
prstat Display process performance-related statistics.
ps List process information.
psig Lists signal actions.
pstack Prints a hex+symbolic stack trace for each LWP in the process.
/usr/bin/pstack [pid | core]
pstop Stops the process (PR_REQUESTED stop).
/usr/bin/pstop pid
ptime Time the command, like 'time', but using microstate accounting for reproducible precision.; (does not time children).
/usr/bin/ptime command [arg]
ptree Prints process genealogy.
pwait Wait for specified processes to complete.
/usr/bin/pwait [-v] pid
pwdx Prints current working directory of each process.
/usr/bin/pwdx pid

See the referenced man page for details for each commands.

Examples

  • pcred
    # pcred 4083
    4083:   e/r/suid=0  e/r/sgid=0
            groups: 0 1 2 3 4 5 6 7 8 9 12
    
    # pcred -l bin 4083
    
    # pcred 4083
    4083:   e/r/suid=2  e/r/sgid=2
            groups: 2 3
    
    # ps -ef | grep sleep
         bin  4083  3803   0 12:24:11 pts/3       0:00 sleep 6000
  • pfiles
    # pfiles 4083
    4083:   sleep 6000
      Current rlimit: 256 file descriptors
       0: S_IFCHR mode:0620 dev:287,0 ino:12582922 uid:0 gid:7 rdev:24,3
          O_RDWR|O_NOCTTY|O_LARGEFILE
          /devices/pseudo/pts@0:3
       1: S_IFCHR mode:0620 dev:287,0 ino:12582922 uid:0 gid:7 rdev:24,3
          O_RDWR|O_NOCTTY|O_LARGEFILE
          /devices/pseudo/pts@0:3
       2: S_IFCHR mode:0620 dev:287,0 ino:12582922 uid:0 gid:7 rdev:24,3
          O_RDWR|O_NOCTTY|O_LARGEFILE
          /devices/pseudo/pts@0:3
  • pflags
    # pflags 4083
    4083:   sleep 6000
            data model = _ILP32  flags = MSACCT|MSFORK
     /1:    flags = ASLEEP  nanosleep(0x8047d58,0x8047d60)
  • pldd
    # pldd 4083
    4083:   sleep 6000
    /lib/libc.so.1
  • pmap
    # pmap 4083
    4083:   sleep 6000
    08047000       4K rw---    [ stack ]
    08050000       4K r-x--  /usr/bin/sleep
    08061000       4K rw---  /usr/bin/sleep
    08062000       8K rw---    [ heap ]
    FEE80000    1080K r-x--  /lib/libc.so.1
    FEF90000      24K rwx--    [ anon ]
    FEF9E000      32K rw---  /lib/libc.so.1
    FEFA6000       8K rw---  /lib/libc.so.1
    FEFC3000     160K r-x--  /lib/ld.so.1
    FEFF0000       4K rwx--    [ anon ]
    FEFF3000       4K rwxs-    [ anon ]
    FEFFB000       8K rwx--  /lib/ld.so.1
    FEFFD000       4K rwx--  /lib/ld.so.1
     total      1344K
  • psig
    # psig 4083
    4083:   sleep 6000
    HUP     default
    INT     default
    QUIT    default
    ILL     default
    TRAP    default
    ABRT    default
    EMT     default
    FPE     default
    KILL    default
    BUS     default
    SEGV    default
    SYS     default
    [...]
  • pstack
    # pstack 4083
    4083:   sleep 6000
     fef298b5 nanosleep (8047d58, 8047d60)
     080508fa main     (2, 8047db0, 8047dbc) + c2
     080507a2 ???????? (2, 8047e70, 8047e76, 0, 8047e7b, 8047ea1)
  • pwdx
    # pwdx 4083
    4083:   /root
  • ptime
    # ptime sleep 10
    
    real       10.005
    user        0.000
    sys         0.002
  • prstat (sort the output to look for the processes with heavy memory usage)
    # prstat -s rss
    PID   USERNAME SIZE  RSS   STATE PRI NICE TIME    CPU  PROCESS/NLWP
    471   root     125M  58M   sleep 59  0    4:26:46 0.6% nsrexecd/17
    200   root     62M   55M   sleep 59  0    0:01:21 0.0% nsrd/4
    18296 root     116M  39M   sleep 26  11   0:05:36 0.1% nsrexecd/23
    ...
    254   root     3968K 1016K sleep 59  0    0:00:03 0.0% sshd/1
    Total: 47 processes, 221 lwps, load averages: 0.20, 0.21, 0.20
  • pgrep
    # ps -ef | grep more | grep -v grep
    root 18494 8025 0 08:53:09 pts/3 0:00 more
    # pgrep more
    18494
  • pmap
    # pmap -x 18494
    18494: more
    Address  Kbytes  RSS     Anon    Locked  Mode   Mapped File
    00010000 32      32      -       -       r-x--  more
    00028000 8       8       8       -       rwx--  more
    0002A000 16      16      16      -       rwx--  [ heap ]
    FF200000 864     824     -       -       r-x--  libc.so.1
    FF2E8000 32      32      32      -       rwx--  libc.so.1
    FF2F0000 8       8       8       -       rwx--  libc.so.1
    FF300000 16      16      -       -       r-x--  en_US.ISO8859-1.so.3
    FF312000 16      16      16      -       rwx--  en_US.ISO8859-1.so.3
    FF330000 8       8       -       -       r-x--  libc_psr.so.1
    FF340000 8       8       8       -       rwx--  [ anon ]
    FF350000 168     104     -       -       r-x--  libcurses.so.1
    FF38A000 32      32      24      -       rwx--  libcurses.so.1
    FF392000 8       8       8       -       rwx--  libcurses.so.1
    FF3A0000 24      16      16      -       rwx--  [ anon ]
    FF3B0000 184     184     -       -       r-x--  ld.so.1
    FF3EE000 8       8       8       -       rwx--  ld.so.1
    FF3F0000 8       8       8       -       rwx--  ld.so.1
    FFBFC000 16      16      16      -       rw---  [ stack ]
    -------- ------- ------- ------- -------
    total Kb 1456    1344    168     -
  • pstack
    # pstack 18494
    18494: more
    ff2c0c7c read (2, ffbff697, 1)
    00015684 ???????? (0, 1, 43858, ff369ad4, 0, 28b20)
    000149a4 ???????? (ffbff82f, 28400, 15000000, 28af6, 0, 28498)
    00013ad8 ???????? (0, 28b10, 28c00, 400b0, ff2a4a74, 0)
    00012780 ???????? (2a078, ff393050, 0, 28b00, 2a077, 6b)
    00011c68 main (28b10, ffffffff, 28c00, 0, 0, 1) + 684
    000115cc _start (0, 0, 0, 0, 0, 0) + 108
  • pfiles
    # pfiles 18494
    18494: more
    Current rlimit: 256 file descriptors
    0: S_IFIFO mode:0000 dev:292,0 ino:2083873 uid:0 gid:0 size:0
    O_RDWR
    1: S_IFCHR mode:0620 dev:284,0 ino:12582922 uid:1000 gid:7 rdev:24,3
    O_RDWR|O_NOCTTY|O_LARGEFILE
    /devices/pseudo/pts@0:3
    2: S_IFCHR mode:0620 dev:284,0 ino:12582922 uid:1000 gid:7 rdev:24,3
    O_RDWR|O_NOCTTY|O_LARGEFILE
    /devices/pseudo/pts@0:3
  • pcred
    # pcred 18494
    18494: e/r/suid=0 e/r/sgid=0
    groups: 0 1 2 3 4 5 6 7 8 9 12