librb: use readlink(2) on linux for the direct path instead of dlinfo

This commit is contained in:
William Pitcock 2016-03-21 21:26:28 -05:00
parent b7c7f290c7
commit 87b20cbb75

View file

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