1
0
Fork 0
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:
David Carlier 2019-08-19 15:36:47 +01:00 committed by Nobuyoshi Nakada
parent 1408f15921
commit e6b72e8cae
Notes: git 2019-08-31 04:40:14 +09:00

View file

@ -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