void get_exe_path(char *result)
{
// Get executable path
- pid_t pid = getpid();
- char proc_path[BCTEXTLEN];
- int len = 0;
- result[0] = 0;
- sprintf(proc_path, "/proc/%d/exe", pid);
- if((len = readlink(proc_path, result, BCTEXTLEN)) >= 0)
- {
+ int len = readlink("/proc/self/exe", result, BCTEXTLEN);
+ if( len >= 0 ) {
result[len] = 0;
-//printf("Preferences::Preferences %d %s\n", __LINE__, result);
char *ptr = strrchr(result, '/');
- if(ptr) *ptr = 0;
+ if( ptr ) *ptr = 0;
}
-
+ else
+ result[0] = 0;
}
-