怎样判断系统中某个进程已经是"挂起"的状态?
如题,谢谢 问题点数:50、回复次数:5Top
1 楼slone(slone)回复于 2005-08-02 09:46:27 得分 10
ps -aux |grep 进程 |grep 状态
两次过滤就行了Top
2 楼seansoe(www.sysmgmt.com.cn)回复于 2005-08-02 18:05:25 得分 0
谢谢楼上的解答。问题是通过ps命令能够得到进程是否"挂起"的状态吗?Top
3 楼seansoe(www.sysmgmt.com.cn)回复于 2005-08-03 22:35:50 得分 0
upTop
4 楼slone(slone)回复于 2005-08-04 09:39:55 得分 20
ps -aux |grep 进程 |grep S
行的第一字母为 STop
5 楼playmud((猪头流氓)(抵制日货)(热烈庆祝火箭输球))回复于 2005-08-04 09:47:43 得分 20
//------------------------------------------------------------------------------
//函数原型: int playmud::Module_Node::module_status()
//功能描述: 检查模块运行状态
//输入参数: 无
//输出参数: 无
//返 回 值: int类型,正常返回0,僵死返回1,不存在返回-1
//其它说明: 无
//------------------------------------------------------------------------------
int playmud::Module_Node::module_status()
{
std::string pid_status;
std::stringstream tmp;
tmp<<"/proc/"<<Pid<<"/status";
tmp>>pid_status;
std::ifstream file_stat(pid_status.c_str(),std::ios::in);
if(!file_stat.is_open())
{
gLogServer.Error("OPEN Failed!!");
return -1;
}
std::string file_line;
getline(file_stat,file_line,'\n');
getline(file_stat,file_line,'\n');
file_stat.close();
if(file_line.find("sleeping")!=std::string::npos ||file_line.find("running")!=std::string::npos)
return 0;
return 1;
}Top




