From 87b20cbb75c8994453ad921692a1e7afffd637ad Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Mon, 21 Mar 2016 21:26:28 -0500 Subject: [PATCH] librb: use readlink(2) on linux for the direct path instead of dlinfo --- librb/src/unix.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/librb/src/unix.c b/librb/src/unix.c index 10c8051e0..d1ae702e3 100644 --- a/librb/src/unix.c +++ b/librb/src/unix.c @@ -165,16 +165,16 @@ rb_path_to_self(void) return NULL; realpath(s, path_buf); return path_buf; +#elif defined(__linux__) + if (readlink("/proc/self/exe", path_buf, sizeof path_buf) != -1) + return path_buf; + return NULL; #elif defined(HAVE_DLINFO) struct link_map *map = NULL; dlinfo(RTLD_SELF, RTLD_DI_LINKMAP, &map); if (map == NULL) return NULL; realpath(map->l_name, path_buf); -#elif defined(__linux__) - if (readlink("/proc/self/exe", path_buf, sizeof path_buf) != -1) - return path_buf; - return NULL; #elif defined(__APPLE__) char tmp_path[4096]; uint32_t pathlen = 4096;