//proc/9744$ cat statushtml
Name: gedit /*进程的程序名*/
State: S (sleeping) /*进程的状态信息,具体参见http://blog.chinaunix.net/u2/73528/showart_1106510.html*/
Tgid: 9744 /*线程组号*/
Pid: 9744 /*进程pid*/
PPid: 7672 /*父进程的pid*/
TracerPid: 0 /*跟踪进程的pid*/
Uid: 1000 1000 1000 1000 /*uid euid suid fsuid*/
Gid: 1000 1000 1000 1000 /*gid egid sgid fsgid*/
FDSize: 256 /*文件描述符的最大个数,file->fds*/
Groups: 0 4 20 24 25 29 30 44 46 107 109 115 124 1000 /*启动该进程的用户所属的组的id*/
VmPeak: 60184 kB /*进程地址空间的大小*/
VmSize: 60180 kB /*进程虚拟地址空间的大小reserved_vm:进程在预留或特殊的内存间的物理页*/
VmLck: 0 kB /*进程已经锁住的物理内存的大小.锁住的物理内存不能交换到硬盘*/
VmHWM: 18020 kB /*文件内存映射和匿名内存映射的大小*/
VmRSS: 18020 kB /*应用程序正在使用的物理内存的大小,就是用ps命令的参数rss的值 (rss)*/
VmData: 12240 kB /*程序数据段的大小(所占虚拟内存的大小),存放初始化了的数据*/
VmStk: 84 kB /*进程在用户态的栈的大小*/
VmExe: 576 kB /*程序所拥有的可执行虚拟内存的大小,代码段,不包括任务使用的库 */
VmLib: 21072 kB /*被映像到任务的虚拟内存空间的库的大小*/
VmPTE: 56 kB /*该进程的全部页表的大小*/
Threads: 1 /*共享使用该信号描述符的任务的个数*/
SigQ: 0/8183 /*待处理信号的个数/目前最大能够处理的信号的个数*/
SigPnd: 0000000000000000 /*屏蔽位,存储了该线程的待处理信号*/
ShdPnd: 0000000000000000 /*屏蔽位,存储了该线程组的待处理信号*/
SigBlk: 0000000000000000 /*存放被阻塞的信号*/
SigIgn: 0000000000001000 /*存放被忽略的信号*/
SigCgt: 0000000180000000 /*存放被俘获到的信号*/
CapInh: 0000000000000000 /*能被当前进程执行的程序的继承的能力*/
CapPrm: 0000000000000000 /*进程可以使用的能力,能够包含CapEff中没有的能力,这些能力是被进程本身临时放弃的*/
CapEff: 0000000000000000 /*是CapPrm的一个子集,进程放弃没有必要的能力有利于提升安全性*/
Cpus_allowed: 01 /*能够执行该进程的CPU掩码集*/
Mems_allowed: 1 /**/
voluntary_ctxt_switches: 1241 /*进程主动切换的次数*/
nonvoluntary_ctxt_switches: 717 /*进程被动切换的次数*/安全
/proc/PID/stat各个字段的描述session
Is there a pgm that will interpret all the fields that are printed by cat /proc/PID/stat ( or statm, or any of the info on a per process basis ) See if the following simple function and the associated structure that I put together sometime ago while checking out some threads- related stuff on Linux/Alpha is of use. Also note that the format characters as given in the man page for proc are not all correct on Alpha. I just when to the sources to get them right (RTFS?:-)) typedef struct statstruct_proc { 一、int pid; /** The process id. **/ 二、char exName [_POSIX_PATH_MAX]; /** The filename of the executable **/ 三、char state; /** 1 **/ /** R is running, S is sleeping, D is sleeping in an uninterruptible wait, Z is zombie, T is traced or stopped **/ 四、unsigned euid, /** effective user id **/ egid; /** effective group id */ 五、int ppid; /** The pid of the parent. **/ 六、int pgrp; /** The pgrp of the process. process group**/ 七、int session; /** The session id of the process. **/ 八、int tty; /** The tty the process uses **/ 九、int tpgid; /** (too long) **/ 十、unsigned int flags; /** The flags of the process. **/ 十一、unsigned int minflt; /** The number of minor faults **/ 十二、unsigned int cminflt; /** The number of minor faults with childs **/ 1三、unsigned int majflt; /** The number of major faults **/ 1四、unsigned int cmajflt; /** The number of major faults with childs **/ 1五、int utime; /** user mode jiffies **/ 1六、int stime; /** kernel mode jiffies **/ 1七、int cutime; /** user mode jiffies with childs **/ 1八、int cstime; /** kernel mode jiffies with childs **/ 1九、int counter; /** process's next timeslice **/ 20、int priority; /** the standard nice value, plus fifteen **/ 2一、unsigned int timeout; /** The time in jiffies of the next timeout **/ 2二、unsigned int itrealvalue; /** The time before the next SIGALRM is sent to the process **/ 2三、int starttime; /** 20 **/ /** Time the process started after system boot **/ 2四、unsigned int vsize; /** Virtual memory size **/ 2五、unsigned int rss; /** Resident Set Size **/ 2六、unsigned int rlim; /** Current limit in bytes on the rss **/ 2七、unsigned int startcode; /** The address above which program text can run **/ 2八、unsigned int endcode; /** The address below which program text can run **/ 2九、unsigned int startstack; /** The address of the start of the stack **/ 30、unsigned int kstkesp; /** The current value of ESP **/ 3一、unsigned int kstkeip; /** The current value of EIP **/ 3二、int signal; /** The bitmap of pending signals **/ 3三、int blocked; /** 30 **/ /** The bitmap of blocked signals **/ 3四、int sigignore; /** The bitmap of ignored signals **/ 3五、int sigcatch; /** The bitmap of catched signals **/ 3六、unsigned int wchan; /** 33 **/ /** (too long) **/ 3七、int sched, /** scheduler **/ sched_priority; /** scheduler priority **/ } procinfo; int get_proc_info(pid_t pid, procinfo * pinfo) { char szFileName [_POSIX_PATH_MAX], szStatStr [2048], *s, *t; FILE *fp; struct stat st; if (NULL == pinfo) { errno = EINVAL; return -1; } sprintf (szFileName, "/proc/%u/stat", (unsigned) pid); if (-1 == access (szFileName, R_OK)) { return (pinfo->pid = -1); } /** if **/ if (-1 != stat (szFileName, &st)) { pinfo->euid = st.st_uid; pinfo->egid = st.st_gid; } else { pinfo->euid = pinfo->egid = -1; } if ((fp = fopen (szFileName, "r")) == NULL) { return (pinfo->pid = -1); } /** IF_NULL **/ if ((s = fgets (szStatStr, 2048, fp)) == NULL) { fclose (fp); return (pinfo->pid = -1); } /** pid **/ sscanf (szStatStr, "%u", &(pinfo->pid)); s = strchr (szStatStr, '(') + 1; t = strchr (szStatStr, ')'); strncpy (pinfo->exName, s, t - s); pinfo->exName [t - s] = ''; sscanf (t + 2, "%c %d %d %d %d %d %u %u %u %u %u %d %d %d %d %d %d %u %u %d %u %u %u %u %u %u %u %u %d %d %d %d %u", /* 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33*/ &(pinfo->state), &(pinfo->ppid), &(pinfo->pgrp), &(pinfo->session), &(pinfo->tty), &(pinfo->tpgid), &(pinfo->flags), &(pinfo->minflt), &(pinfo->cminflt), &(pinfo->majflt), &(pinfo->cmajflt), &(pinfo->utime), &(pinfo->stime), &(pinfo->cutime), &(pinfo->cstime), &(pinfo->counter), &(pinfo->priority), &(pinfo->timeout), &(pinfo->itrealvalue), &(pinfo->starttime), &(pinfo->vsize), &(pinfo->rss), &(pinfo->rlim), &(pinfo->startcode), &(pinfo->endcode), &(pinfo->startstack), &(pinfo->kstkesp), &(pinfo->kstkeip), &(pinfo->signal), &(pinfo->blocked), &(pinfo->sigignore), &(pinfo->sigcatch), &(pinfo->wchan)); fclose (fp); return 0; }