Skip to content

Commit

Permalink
fix get own_dir on Linux glibc
Browse files Browse the repository at this point in the history
  • Loading branch information
soflare authored and zliang7 committed Nov 8, 2020
1 parent 583343a commit a51a92e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,12 @@ int main(int argc, char *argv[]) {

Dl_info dli;
dladdr(own_dir, &dli);
set_own_dir(dli.dli_fname);
if (dli.dli_fname[0] == '/')
set_own_dir(dli.dli_fname);
else if (readlink("/proc/self/exe", own_dir, sizeof(own_dir)) < sizeof(own_dir))
set_own_dir(own_dir);
else
set_own_dir(argv[0]);

i = 0;

Expand Down

0 comments on commit a51a92e

Please sign in to comment.