判断指定pid号的进程是否存在

判断指定进程是否存在

// 存在返回1
int process_exist(char *pid)
{
    
    
	int ret = 0;
	char pid_path[64] = {
    
    0};
	struct stat stat_buf;
	if(!pid)
		return 0;
	snprintf(pid_path, 64, "/proc/%s/status", pid);
	if (stat(pid_path, &stat_buf) == 0)
		ret = 1;
	return ret;
}



猜你喜欢

转载自blog.csdn.net/G_Super_Mouse/article/details/109732535