我想检查一个进程是否仍在运行 - 如果是,请更新当前时间 - 如果没有返回函数 bc 进程已经死亡......如果进程没有死亡并且停止限制已经过去,那么你退出循环但似乎 currTime 没有更新......
int g_iStopLimit = 30; //declared globally
/////process gets signaled to be killed but may take a while to close cleanly...
time_t startTime, currTime;
time(&startTime);
currTime = time(NULL);
do //check to see if process gets killed
{
if (kill(g_StatusInstance[i].pid, 0) == 0) //some global array
{
currTime = time(NULL);
}
else
{
return;
}
}while(currTime >= (startTime + g_iStopLimit));
////send a stronger signal and call kill - use recursion and call function over until it kills it