Skip to content

Commit

Permalink
Throw exception when 'readlink(/proc/self/exe)' fails on Linux.
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasBanana committed Sep 15, 2023
1 parent 8fff00f commit 7555b23
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion sources/Platform/Linux/LinuxModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@

#include "LinuxModule.h"
#include "../../Core/CoreUtils.h"
#include "../../Core/Exception.h"
#include <dlfcn.h>
#include <unistd.h>
#include <stdexcept>
#include <errno.h>
#include <string.h>


namespace LLGL
Expand All @@ -21,7 +24,12 @@ static std::string GetProgramPath()
{
/* Get filename of running program */
char buf[1024] = { 0 };
(void)readlink("/proc/self/exe", buf, sizeof(buf));
ssize_t bufSize = readlink("/proc/self/exe", buf, sizeof(buf));
if (bufSize == -1)
{
int errorCode = errno;
LLGL_TRAP("readlink(/proc/self/exe) failed: errno=%d (%s)", errorCode, strerror(errorCode));
}

/* Get path from program */
std::string path = buf;
Expand Down

0 comments on commit 7555b23

Please sign in to comment.