]> Savannah Git Hosting - gnulib.git/commitdiff
progreloc: Simplify code for Android.
authorBruno Haible <bruno@clisp.org>
Tue, 19 Feb 2019 20:38:53 +0000 (21:38 +0100)
committerBruno Haible <bruno@clisp.org>
Tue, 19 Feb 2019 20:38:53 +0000 (21:38 +0100)
* lib/progreloc.c (executable_fd): Don't define on Android.
(maybe_executable, find_executable): Don't use executable_fd on Android.

ChangeLog
lib/progreloc.c

index 64e9acf69e744017534e21fce03e83666d4dbb0d..9cb7ac8de53641f83436a46c1feaa1351a5d0f1c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
index 1c4db0c6f175f9a9d5feae8093e1c60d8a448def..0cd335ec38576dcc10b198ac36aa1d03971c4e81 100644 (file)
@@ -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/<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 @@ 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/<pid>/exe, at least in
      Cygwin >= 1.5.  */