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. **/
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 **/
unsigned int majflt; /** The number of major faults **/
unsigned int cmajflt; /** The number of major faults with childs **/
int utime; /** user mode jiffies **/
int stime; /** kernel mode jiffies **/
int cutime; /** user mode jiffies with childs **/
int cstime; /** kernel mode jiffies with childs **/
int counter; /** process's next timeslice **/
int priority; /** the standard nice value, plus fifteen **/
unsigned int timeout; /** The time in jiffies of the next timeout **/
unsigned int itrealvalue; /** The time before the next SIGALRM is sent to the process **/
int starttime; /** 20 **/ /** Time the process started after system boot **/
unsigned int vsize; /** Virtual memory size **/
unsigned int rss; /** Resident Set Size **/
unsigned int rlim; /** Current limit in bytes on the rss **/
unsigned int startcode; /** The address above which program text can run **/
unsigned int endcode; /** The address below which program text can run **/
unsigned int startstack; /** The address of the start of the stack **/
unsigned int kstkesp; /** The current value of ESP **/
unsigned int kstkeip; /** The current value of EIP **/
int signal; /** The bitmap of pending signals **/
int blocked; /** 30 **/ /** The bitmap of blocked signals **/
int sigignore; /** The bitmap of ignored signals **/
int sigcatch; /** The bitmap of catched signals **/
unsigned int wchan; /** 33 **/ /** (too long) **/
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, ')');文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!
/proc/
来源:互联网
作者:west263.com
时间:2008-04-16
西部数码-全国虚拟主机10强!40余项虚拟主机管理功能,全国领先!双线多线虚拟主机南北访问畅通无阻!免费赠送企业邮局,.CN域名,自助建站480元起,免费试用7天,满意再付款! P4主机租用799元/月.月付免压金!
/proc/<pid>/stat各个字段的描述
热点关注
- 快速学习如何搭建一个赚钱
- 什么是CPA、CPC、CPM、CPO
- 论文:Web安全对策研究
- 新手站长35天自学引路
- 站长资讯网第二版上线
- 网络营销网站功能设计的几
- 女站长的建站理财文章
- 也谈域名备案 -- 撤销已存
- 自己动手做网站 个人站长
- 对第一次做网站的朋友说些
- 传统网站逼得Web2.0没法活
- 被K过的域名如何被百度重
- 如何选择理想IDC服务商十
- 技巧:Vimdiff 使用
- 网络创业经历 靠卖域名来
- 如何提高网站流量之小节
- 王晨昀:个人网站为什么要
- 企业开展网络营销存在的误
- 一个失败者谈地方门户的运
- 域名注册与虚拟主机的选购
- SEO360的搜索引擎优化推广
- 网站运营与网络运营的一字
- 做网站要做出自己的个性—
- 中国网站内容不可逾越的三
- 如何将新网及商务中国的域
- 08年,个人站长赚钱将更加
- 保证能增加RSS订阅量的35
- 企业网站英文版制作几个关
- 龚文祥:互联网运营关键词
- 我的行业垃圾站
- 2008最新申请Google adsen
- 虚拟主机的陷阱
- 网站建设发展的几点中肯建
- 企业如何安全高效使用垃圾
- 计算机文件夹删除不掉怎么
IDC资讯
虚拟主机
域名注册
托管租用
vps主机
智能建站
网站运营 建站经验 策划盈利 搜索优化 网站推广 免费资源
网站联盟 联盟新闻 联盟介绍 联盟点评 网赚技巧
行业资讯 业界动态 搜索引擎 网络游戏 门户动态 电子商务 广告传媒
网络编程 Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术 Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷 Internet Explorer
网页制作 FrontPages Dreamweaver Javascript css photoshop fireworks Flash
程序设计 Java技术 C/C++ VB delphi
网络知识 网络协议 网络安全 网络管理 组网方案 Cisco技术
操作系统 Win2000 WinXP Win2003 Mac OS Linux FreeBSD
网站运营 建站经验 策划盈利 搜索优化 网站推广 免费资源
网站联盟 联盟新闻 联盟介绍 联盟点评 网赚技巧
行业资讯 业界动态 搜索引擎 网络游戏 门户动态 电子商务 广告传媒
网络编程 Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术 Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷 Internet Explorer
网页制作 FrontPages Dreamweaver Javascript css photoshop fireworks Flash
程序设计 Java技术 C/C++ VB delphi
网络知识 网络协议 网络安全 网络管理 组网方案 Cisco技术
操作系统 Win2000 WinXP Win2003 Mac OS Linux FreeBSD



