char line[LINE_MAX],*serr,eacces=0;
char line[LINE_MAX],eacces=0;
static void prg_cache_load(void){    char line[LINE_MAX],*serr,eacces=0;    int procfdlen,fd,cmdllen,lnamelen;    char lname[30],cmdlbuf[512],finbuf[PROGNAME_WIDTH];    long inode;    const char *cs,*cmdlp;    DIR *dirproc=NULL,*dirfd=NULL;    struct dirent *direproc,*direfd;    if (prg_cache_loaded || !flag_prg) return;    prg_cache_loaded=1;    cmdlbuf[sizeof(cmdlbuf)-1]='\0';    if (!(dirproc=opendir(PATH_PROC))) goto fail;    while (errno=0,direproc=readdir(dirproc)) {#ifdef DIRENT_HAVE_D_TYPE_WORKS	if (direproc->d_type!=DT_DIR) continue;#endif	for (cs=direproc->d_name;*cs;cs++)	    if (!isdigit(*cs)) 		break;	if (*cs) 	    continue;	procfdlen=snprintf(line,sizeof(line),PATH_PROC_X_FD,direproc->d_name);	if (procfdlen<=0 || procfdlen>=sizeof(line)-5) 	    continue;	errno=0;	dirfd=opendir(line);	if (! dirfd) {	    if (errno==EACCES) 		eacces=1;	    continue;	}	line[procfdlen] = '/';	cmdlp = NULL;	while ((direfd = readdir(dirfd))) {#ifdef DIRENT_HAVE_D_TYPE_WORKS	    if (direfd->d_type!=DT_LNK) 		continue;#endif	    if (procfdlen+1+strlen(direfd->d_name)+1>sizeof(line)) 		continue;	    memcpy(line + procfdlen - PATH_FD_SUFFl, PATH_FD_SUFF "/",		   PATH_FD_SUFFl+1);	    strcpy(line + procfdlen + 1, direfd->d_name);	    lnamelen=readlink(line,lname,sizeof(lname));	    if (lnamelen < strlen(PRG_SOCKET_PFX+2)) 		continue;	    if (memcmp(lname, PRG_SOCKET_PFX, PRG_SOCKET_PFXl)		|| lname[lnamelen-1]!=']') 		continue;	    lname[lnamelen-1]='\0';	    inode = strtol(lname+PRG_SOCKET_PFXl,&serr,0);	    if (!serr || *serr || inode < 0 || inode >= INT_MAX) 		continue;	    if (!cmdlp) {		if (procfdlen - PATH_FD_SUFFl + PATH_CMDLINEl >= 		    sizeof(line) - 5) 		    continue;		strcpy(line + procfdlen-PATH_FD_SUFFl, PATH_CMDLINE);		fd = open(line, O_RDONLY);		if (fd < 0) 		    continue;		cmdllen = read(fd, cmdlbuf, sizeof(cmdlbuf) - 1);		if (close(fd)) 		    continue;		if (cmdllen == -1) 		    continue;		if (cmdllen < sizeof(cmdlbuf) - 1) 		    cmdlbuf[cmdllen]='\0';		if ((cmdlp = strrchr(cmdlbuf, '/'))) 		    cmdlp++;		else 		    cmdlp = cmdlbuf;	    }	    snprintf(finbuf, sizeof(finbuf), "%s/%s", direproc->d_name, cmdlp);	    prg_cache_add(inode, finbuf);	}	closedir(dirfd); 	dirfd = NULL;    }    if (dirproc) 	closedir(dirproc);    if (dirfd) 	closedir(dirfd);    if (!eacces) 	return;    if (prg_cache_loaded == 1) {    fail:	fprintf(stderr,_("(No info could be read for \"-p\": geteuid()=%d but you should be root.)\n"),		geteuid());    }    else	fprintf(stderr, _("(Not all processes could be identified, non-owned process info\n"			 " will not be shown, you would have to be root to see it all.)\n"));}