diff options
author | David Carlier <[email protected]> | 2019-08-19 15:36:47 +0100 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2019-08-20 02:05:10 +0900 |
commit | e6b72e8cae786c9752cc34541b58b5635d5c76bb (patch) | |
tree | f0adadf1f44e2d7e30242f1fe3adfec46398627e /addr2line.c | |
parent | 1408f15921a8a051055a68fb96e050a7d4cd35fb (diff) |
retrieve current path on macOS
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/2390
Diffstat (limited to 'addr2line.c')
-rw-r--r-- | addr2line.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/addr2line.c b/addr2line.c index 9e7df4e7fb..635194b96b 100644 --- a/addr2line.c +++ b/addr2line.c @@ -21,6 +21,10 @@ #include <stdio.h> #include <errno.h> +#ifdef HAVE_LIBPROC_H +#include <libproc.h> +#endif + #ifdef HAVE_STDBOOL_H #include <stdbool.h> #else @@ -2068,6 +2072,15 @@ main_exe_path(void) len--; /* sysctl sets strlen+1 */ return len; } +#elif defined(HAVE_LIBPROC_H) +static ssize_t +main_exe_path(void) +{ + int len = proc_pidpath(getpid(), binary_filename, PATH_MAX); + if (len == 0) return 0; + binary_filename[len] = 0; + return len; +} #else #undef HAVE_MAIN_EXE_PATH #endif |