Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Try /proc/$PID/exe if /proc/self/exe doesn't work out.
  • Loading branch information
icculus committed Jul 8, 2009
1 parent 4320727 commit 44f6c83
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/platform_unix.c
Expand Up @@ -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, '/');
Expand Down

0 comments on commit 44f6c83

Please sign in to comment.