Handle readlink errors (#1292)

This commit is contained in:
Julien Voisin 2023-01-05 21:59:45 +01:00 committed by GitHub
parent 72c0ad768e
commit 6c6e5e9b99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -36,7 +36,8 @@ static void get_exe_filename(char *buf, int sz) {
buf[len] = '\0'; buf[len] = '\0';
#elif __linux__ #elif __linux__
char path[] = "/proc/self/exe"; 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'; buf[len] = '\0';
#elif __APPLE__ #elif __APPLE__
/* use realpath to resolve a symlink if the process was launched from one. /* use realpath to resolve a symlink if the process was launched from one.