From 63cb0775ef17d27cc3f3d1b18f20923c66c13dde Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 17 Oct 2019 13:17:19 -0400 Subject: [PATCH] handle the case where /proc/self/fd/# does not exist (anymore) --- src/utils.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils.cpp b/src/utils.cpp index 7262f8d8b8..8f1dadad0b 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -150,7 +150,8 @@ void utils::sfread(const char *srcname, int srcline, void *s, size_t size, int fd = fileno(fp); snprintf(procpath,32,"/proc/self/fd/%d",fd); memset(inferred_name,0,MAXFILEBUF); - readlink(procpath,inferred_name,MAXFILEBUF); + if (readlink(procpath,inferred_name,MAXFILEBUF) <= 0) + strcpy(inferred_name,"(unknown)"); #else strcpy(inferred_name,"(unknown)"); #endif