mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
retrieve current path on macOS
This commit is contained in:
parent
1408f15921
commit
e6b72e8cae
Notes:
git
2019-08-31 04:40:14 +09:00
1 changed files with 13 additions and 0 deletions
13
addr2line.c
13
addr2line.c
|
@ -21,6 +21,10 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBPROC_H
|
||||||
|
#include <libproc.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_STDBOOL_H
|
#ifdef HAVE_STDBOOL_H
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#else
|
#else
|
||||||
|
@ -2068,6 +2072,15 @@ main_exe_path(void)
|
||||||
len--; /* sysctl sets strlen+1 */
|
len--; /* sysctl sets strlen+1 */
|
||||||
return len;
|
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
|
#else
|
||||||
#undef HAVE_MAIN_EXE_PATH
|
#undef HAVE_MAIN_EXE_PATH
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue