判断进程是否存在
/***************************************************************************
function: ProcessExistCheck
input:
output:
Description:判断进程是否存在
****************************************************************************/
bool ProcessExistCheck(char *szProcess)
{
FILE *ptFile = NULL;
char szBuff[32] = {0};
char szCmd[128] = {0};
uint32 iRet = 0;
sprintf(szCmd, "ps -aux | grep -v grep | grep -cw \"%s\"", szProcess);
ptFile = popen(szCmd, "r");
if(NULL != ptFile)
{
if(fgets(szBuff, sizeof(szBuff), ptFile) != NULL)
{
iRet = atoi(szBuff);
if(iRet > 1)
{
pclose(ptFile);
return true;
}
}
}
pclose(ptFile);
return false;
}