From 44f6c8306dc6f02f5d6e97c1bad82166350146d8 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 8 Jul 2009 17:53:48 -0400 Subject: [PATCH] Try /proc/$PID/exe if /proc/self/exe doesn't work out. --- src/platform_unix.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/platform_unix.c b/src/platform_unix.c index 2dbd323f..f63e4656 100644 --- a/src/platform_unix.c +++ b/src/platform_unix.c @@ -245,6 +245,16 @@ char *__PHYSFS_platformCalcBaseDir(const char *argv0) * the /proc/self/exe symlink. */ retval = readSymLink("/proc/self/exe"); + if (retval == NULL) + { + /* older kernels don't have /proc/self ... try PID version... */ + const unsigned long long pid = (unsigned long long) getpid(); + char path[64]; + const int rc = (int) snprintf(path,sizeof(path),"/proc/%llu/exe",pid); + if ( (rc > 0) && (rc < sizeof(path)) ) + retval = readSymLink(path); + } /* if */ + if (retval != NULL) /* chop off filename. */ { char *ptr = strrchr(retval, '/');