handle the case where /proc/self/fd/# does not exist (anymore)

This commit is contained in:
Axel Kohlmeyer
2019-10-17 13:17:19 -04:00
parent cad6293078
commit 63cb0775ef

View File

@ -150,7 +150,8 @@ void utils::sfread(const char *srcname, int srcline, void *s, size_t size,
int fd = fileno(fp); int fd = fileno(fp);
snprintf(procpath,32,"/proc/self/fd/%d",fd); snprintf(procpath,32,"/proc/self/fd/%d",fd);
memset(inferred_name,0,MAXFILEBUF); memset(inferred_name,0,MAXFILEBUF);
readlink(procpath,inferred_name,MAXFILEBUF); if (readlink(procpath,inferred_name,MAXFILEBUF) <= 0)
strcpy(inferred_name,"(unknown)");
#else #else
strcpy(inferred_name,"(unknown)"); strcpy(inferred_name,"(unknown)");
#endif #endif