>From cd46bf0ca5083162f3ac564ebbdeb6371085df45 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 19 Feb 2019 21:38:53 +0100 Subject: [PATCH 1/2] progreloc: Simplify code for Android. * lib/progreloc.c (executable_fd): Don't define on Android. (maybe_executable, find_executable): Don't use executable_fd on Android. --- ChangeLog | 6 ++++++ lib/progreloc.c | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 64e9acf..9cb7ac8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2019-02-19 Bruno Haible + + progreloc: Simplify code for Android. + * lib/progreloc.c (executable_fd): Don't define on Android. + (maybe_executable, find_executable): Don't use executable_fd on Android. + 2019-02-15 Bruno Haible gnulib-tool: Support --import with just a few tests, not --with-tests. diff --git a/lib/progreloc.c b/lib/progreloc.c index 1c4db0c..0cd335e 100644 --- a/lib/progreloc.c +++ b/lib/progreloc.c @@ -102,7 +102,7 @@ extern char * canonicalize_file_name (const char *name); #if ENABLE_RELOCATABLE -#if defined __linux__ || defined __ANDROID__ || defined __CYGWIN__ +#if defined __linux__ || defined __CYGWIN__ /* File descriptor of the executable. (Only used to verify that we find the correct executable.) */ static int executable_fd = -1; @@ -118,7 +118,7 @@ maybe_executable (const char *filename) return false; #endif -#if defined __linux__ || defined __ANDROID__ || defined __CYGWIN__ +#if defined __linux__ || defined __CYGWIN__ if (executable_fd >= 0) { /* If we already have an executable_fd, check that filename points to @@ -180,7 +180,7 @@ find_executable (const char *argv0) return xstrdup (location); #else /* Unix */ -# if defined __linux__ || defined __ANDROID__ +# if defined __linux__ /* The executable is accessible as /proc//exe. In newer Linux versions, also as /proc/self/exe. Linux >= 2.1 provides a symlink to the true pathname; older Linux versions give only device and ino, @@ -205,6 +205,15 @@ find_executable (const char *argv0) } } # endif +# if defined __ANDROID__ + { + char *link; + + link = xreadlink ("/proc/self/exe"); + if (link != NULL) + return link; + } +# endif # ifdef __CYGWIN__ /* The executable is accessible as /proc//exe, at least in Cygwin >= 1.5. */ -- 2.7.4