Skip to content

Commit

Permalink
/proc/self/exe does not exist on MacOS.
Browse files Browse the repository at this point in the history
Fixes audetto#54

Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
  • Loading branch information
audetto committed Jan 3, 2022
1 parent fa60480 commit 1f1a0f0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions source/frontends/common2/commonframe.cpp
Expand Up @@ -10,6 +10,10 @@
#include <unistd.h>
#include <libgen.h>

#ifdef __APPLE__
#include "mach-o/dyld.h"
#endif

#include "Log.h"
#include "Core.h"
#include "config.h"
Expand All @@ -36,7 +40,14 @@ namespace
std::vector<std::string> paths;

char self[1024] = {0};

#ifdef __APPLE__
uint32_t size = sizeof(self);
const int ch = _NSGetExecutablePath(self, &size);
#else
const int ch = readlink("/proc/self/exe", self, sizeof(self));
#endif

if (ch != -1)
{
const char * path = dirname(self);
Expand Down

0 comments on commit 1f1a0f0

Please sign in to comment.