Handle readlink errors (#1292)
This commit is contained in:
+3
-2
@@ -36,8 +36,9 @@ 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);
|
||||||
buf[len] = '\0';
|
if (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.
|
||||||
** This happens when Homebrew installs a cack and creates a symlink in
|
** This happens when Homebrew installs a cack and creates a symlink in
|
||||||
|
|||||||
Reference in New Issue
Block a user