#define SVP_RCHMI_PROCESS_NAME "rc_hmi"
static pid_t process_pid = 1000;
int main()
{
FILE *fp_handle;
SVPChar buf[128] = {'\0'};
SVPChar cmd[128] = {'\0'};
SVPChar dest_path[128] = {'\0'};
SVPChar cur_task_name[128] = {'\0'};
sprintf(dest_path, "/proc/%d/status", process_pid);
fp_handle= fopen(dest_path, "r");
if(NULL != fp_handle)
{
if( fgets(buf, 128, fp_handle)== NULL )
{
fclose(fp_handle);
Hmi_Service_Flag = 0;
}
fclose(fp_handle);
sscanf(buf, "%*s %s", cur_task_name);
if (strcmp(SVP_RCHMI_PROCESS_NAME, cur_task_name) == 0){
Hmi_Service_Flag = 1;
}
else{
Hmi_Service_Flag = 0;
}
}
else
{
Hmi_Service_Flag = 0;
}
return 0;
}
进程1:由进程ID获取进程名字
最新推荐文章于 2024-07-18 10:20:54 发布