Handle readlink errors (#1292)

This commit is contained in:
Julien Voisin authored and takase1121 committed 2023-08-19 12:28:19 +08:00
1 parent 138cea45d5
commit 1ab320bb9b
1 file changed
+2 -1
+2 -1
View File
@@ -36,7 +36,8 @@ static void get_exe_filename(char *buf, int sz) {
buf[len] = '\0';
#elif __linux__
char path[] = "/proc/self/exe";
int len = readlink(path, buf, sz - 1);
ssize_t len = readlink(path, buf, sz - 1);
if (len > 0)
buf[len] = '\0';
#elif __APPLE__
/* use realpath to resolve a symlink if the process was launched from one.