This is the struct you should read out of /proc/pid
/status:
typedef struct pstatus {
int pr_flags; /* flags (see below) */
int pr_nlwp; /* number of active lwps in the process */
pid_t pr_pid; /* process id */
pid_t pr_ppid; /* parent process id */
pid_t pr_pgid; /* process group id */
pid_t pr_sid; /* session id */
id_t pr_aslwpid; /* historical; now always zero */
id_t pr_agentid; /* lwp id of the /proc agent lwp, if any */
sigset_t pr_sigpend; /* set of process pending signals */
uintptr_t pr_brkbase; /* address of the process heap */
size_t pr_brksize; /* size of the process heap, in bytes */
uintptr_t pr_stkbase; /* address of the process stack */
size_t pr_stksize; /* size of the process stack, in bytes */
timestruc_t pr_utime; /* process user cpu time */
timestruc_t pr_stime; /* process system cpu time */
timestruc_t pr_cutime; /* sum of children's user times */
timestruc_t pr_cstime; /* sum of children's system times */
sigset_t pr_sigtrace; /* set of traced signals */
fltset_t pr_flttrace; /* set of traced faults */
sysset_t pr_sysentry; /* set of system calls traced on entry */
sysset_t pr_sysexit; /* set of system calls traced on exit */
char pr_dmodel; /* data model of the process (see below) */
char pr_pad[3];
taskid_t pr_taskid; /* task id */
projid_t pr_projid; /* project id */
int pr_nzomb; /* number of zombie lwps in the process */
zoneid_t pr_zoneid; /* zone id */
int pr_filler[15]; /* reserved for future use */
lwpstatus_t pr_lwp; /* status of the representative lwp */
} pstatus_t;
Note it's defined in header file procfs.h. Declare a pstatus_t
variable and read sizeof(pstatus_t)
bytes into that variable.
Tip: Also not available through ls
, you can also use /proc/self/psinfo
to read psinfo of self process.