The PIOCPSINFO code returns miscellaneous information about a process and stores it in a structure of type prpsinfo_t, which looks like this in Solaris 2.x (it's slightly different in IRIX 5.x):
typedef struct prpsinfo {
char pr_state; /* numeric process state (see pr_sname) */
char pr_sname; /* printable character representing pr_state */
char pr_zomb; /* !=0: process terminated but not waited for */
char pr_nice; /* nice for cpu usage */
u_long pr_flag; /* process flags */
uid_t pr_uid; /* real user id */
gid_t pr_gid; /* real group id */
pid_t pr_pid; /* unique process id */
pid_t pr_ppid; /* process id of parent */
pid_t pr_pgrp; /* pid of process group leader */
pid_t pr_sid; /* session id */
caddr_t pr_addr; /* physical address of process */
long pr_size; /* size of process image in pages */
long pr_rssize; /* resident set size in pages */
caddr_t pr_wchan; /* wait addr for sleeping process */
timestruc_t pr_start; /* process start time, sec+nsec since epoch */
timestruc_t pr_time; /* usr+sys cpu time for this process */
long pr_pri; /* priority, high value is high priority */
char pr_oldpri; /* pre-SVR4, low value is high priority */
char pr_cpu; /* pre-SVR4, cpu usage for scheduling */
o_dev_t pr_ottydev; /* short tty device number */
dev_t pr_lttydev; /* controlling tty device (PRNODEV if none) */
char pr_clname[PRCLSZ]; /* scheduling class name */
char pr_fname[PRFNSZ]; /* last component of execed pathname */
char pr_psargs[PRARGSZ]; /* initial characters of arg list */
short pr_syscall; /* system call number (if in syscall) */
short pr_fill;
timestruc_t pr_ctime; /* usr+sys cpu time for reaped children */
u_long pr_bysize; /* size of process image in bytes */
u_long pr_byrssize; /* resident set size in bytes */
int pr_argc; /* initial argument count */
char **pr_argv; /* initial argument vector */
char **pr_envp; /* initial environment vector */
int pr_wstat; /* if zombie, the wait() status */
long pr_filler[11]; /* for future expansion */
} prpsinfo_t;
Some of the more interesting fields of this structure are:
pr_sname
A character representation of the process' current state.
The possible values are:
I
Idle; the process is being created.
O
The process is currently running on a processor.
R
Runnable; the process is on the run queue.
S
Sleeping; the process is waiting for an event to complete (such as device input/output).
T
Stopped (traced); the process has been stopped by a signal or because another process is tracing it.
X
SXBRK status; the process is waiting for more primary memory.
Z
Zombie; the process has exited, but its parent has not waited for it yet.
The time the process started; this can be printed with the ctime function, among others.
pr_time
The sum of the process' user and system times.
pr_ctime
The sum of the process' child process' user and system times. This value only includes processes that have exited and been waited on.
pr_pri
The process' scheduling priority; higher values are better than lower ones.
pr_lttydev
The major/minor device numbers of the controlling terminal, or PRNODEV if there isn't one.
pr_fname
The last component of the exec'd path name (i.e., the name of the command).
pr_psargs
The first several bytes of the command and its argument list.
pr_bysize
The size of the process (text segment, data segment, and stack) in bytes.
pr_byrssize
The size of the process' resident set size, the amount of memory the process is actually taking up (which, because of demand paging, is usually much smaller than its total size).