emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master bc6c55c5cf3: Disable exec loader when Emacs is running under an e


From: Po Lu
Subject: master bc6c55c5cf3: Disable exec loader when Emacs is running under an existing instance
Date: Sun, 11 Feb 2024 22:55:17 -0500 (EST)

branch: master
commit bc6c55c5cf3fc5bd248232c6332ea7cca19ffe91
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Disable exec loader when Emacs is running under an existing instance
    
    * src/androidfns.c (syms_of_androidfns_for_pdumper): Check if
    Emacs is running under process tracing, and if so, disable
    android_use_exec_loader.
---
 src/androidfns.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/src/androidfns.c b/src/androidfns.c
index 48c3f3046d6..ea3d5f71c7c 100644
--- a/src/androidfns.c
+++ b/src/androidfns.c
@@ -3216,6 +3216,10 @@ syms_of_androidfns_for_pdumper (void)
   jstring string;
   Lisp_Object language, country, script, variant;
   const char *data;
+  FILE *fd;
+  char *line;
+  size_t size;
+  long pid;
 
   /* Find the Locale class.  */
 
@@ -3386,6 +3390,35 @@ syms_of_androidfns_for_pdumper (void)
 
   /* Set Vandroid_os_language.  */
   Vandroid_os_language = list4 (language, country, script, variant);
+
+  /* Detect whether Emacs is running under libloader.so or another
+     process tracing mechanism, and disable `android_use_exec_loader' if
+     so, leaving subprocesses started by Emacs to the care of that
+     loader instance.  */
+
+  if (android_get_current_api_level () >= 29) /* Q */
+    {
+      fd = fopen ("/proc/self/status", "r");
+      if (!fd)
+       return;
+
+      line = NULL;
+      while (getline (&line, &size, fd) != -1)
+       {
+         if (strncmp (line, "TracerPid:", sizeof "TracerPid:" - 1))
+           continue;
+
+         pid = atol (line + sizeof "TracerPid:" - 1);
+
+         if (pid)
+           android_use_exec_loader = false;
+
+         break;
+       }
+
+      free (line);
+      fclose (fd);
+    }
 }
 
 #endif /* ANDROID_STUBIFY */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]