Mercurial > gnulib
changeset 40188:e13b9344e430
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.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Tue, 19 Feb 2019 21:38:53 +0100 |
parents | 7f943adad683 |
children | 3ba41edecde6 |
files | ChangeLog lib/progreloc.c |
diffstat | 2 files changed, 18 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Tue Feb 19 08:54:45 2019 -0800 +++ b/ChangeLog Tue Feb 19 21:38:53 2019 +0100 @@ -1,3 +1,9 @@ +2019-02-19 Bruno Haible <bruno@clisp.org> + + 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 <bruno@clisp.org> gnulib-tool: Support --import with just a few tests, not --with-tests.
--- a/lib/progreloc.c Tue Feb 19 08:54:45 2019 -0800 +++ b/lib/progreloc.c Tue Feb 19 21:38:53 2019 +0100 @@ -102,7 +102,7 @@ #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 @@ 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 @@ return xstrdup (location); #else /* Unix */ -# if defined __linux__ || defined __ANDROID__ +# if defined __linux__ /* The executable is accessible as /proc/<pid>/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 @@ } } # 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/<pid>/exe, at least in Cygwin >= 1.5. */