mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 10:52:08 +02:00
Platform (Linux): fix exe path detection (#1468)
On error, -1 is returned from readlink()
This commit is contained in:
@@ -21,7 +21,8 @@ static void getExePath(FFPlatform* platform)
|
||||
char exePath[PATH_MAX + 1];
|
||||
#ifdef __linux__
|
||||
ssize_t exePathLen = readlink("/proc/self/exe", exePath, sizeof(exePath) - 1);
|
||||
exePath[exePathLen] = '\0';
|
||||
if (exePathLen >= 0)
|
||||
exePath[exePathLen] = '\0';
|
||||
#elif defined(__APPLE__)
|
||||
int exePathLen = proc_pidpath((int) getpid(), exePath, sizeof(exePath));
|
||||
#elif defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
@@ -44,7 +45,8 @@ static void getExePath(FFPlatform* platform)
|
||||
size_t exePathLen = 0;
|
||||
#elif defined(__sun)
|
||||
ssize_t exePathLen = readlink("/proc/self/path/a.out", exePath, sizeof(exePath) - 1);
|
||||
exePath[exePathLen] = '\0';
|
||||
if (exePathLen >= 0)
|
||||
exePath[exePathLen] = '\0';
|
||||
#endif
|
||||
if (exePathLen > 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user