better binary detection in osx

This commit is contained in:
roberto@mrspurr
2011-07-31 17:25:10 +02:00
parent 699a9bfa8e
commit 500f1e37f6
2 changed files with 10 additions and 3 deletions
+9 -3
View File
@@ -2563,15 +2563,21 @@ void uwsgi_chown(char *filename, char *owner) {
char *uwsgi_get_binary_path(char *argvzero) {
char *buf;
#ifdef __linux__
buf = uwsgi_malloc(uwsgi.page_size);
#if defined(__linux__)
char *buf = uwsgi_malloc(uwsgi.page_size);
ssize_t len = readlink("/proc/self/exe", buf, uwsgi.page_size);
if (len > 0) {
return buf;
}
#elif defined(__APPLE__)
char *buf = uwsgi_malloc(uwsgi.page_size);
uint32_t len = uwsgi.page_size;
if (_NSGetExecutablePath(buf, &len) == 0) {
return buf;
}
#endif
return argvzero;
}
+1
View File
@@ -162,6 +162,7 @@ extern int pivot_root(const char *new_root, const char *put_old);
#ifdef __APPLE__
#define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_4
#include <mach-o/dyld.h>
#endif
#include <dlfcn.h>