emacs-diffs
[Top][All Lists]
Advanced

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

feature/android 2ba6c5035c9: Update Android port


From: Po Lu
Subject: feature/android 2ba6c5035c9: Update Android port
Date: Fri, 5 May 2023 00:10:39 -0400 (EDT)

branch: feature/android
commit 2ba6c5035c904426d564eac47381480158cbbb9e
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Update Android port
    
    * doc/emacs/android.texi (Android Environment): Document lossage
    with SIGSTOP.
    * exec/exec.c (exec_0): Check X_OK on file being opened.  Also
    handle /proc/self/exe.
---
 doc/emacs/android.texi |  5 ++++
 exec/exec.c            | 76 ++++++++++++++++++++++++++++++--------------------
 2 files changed, 51 insertions(+), 30 deletions(-)

diff --git a/doc/emacs/android.texi b/doc/emacs/android.texi
index f2bcc50df23..d7fadd69e4b 100644
--- a/doc/emacs/android.texi
+++ b/doc/emacs/android.texi
@@ -293,6 +293,11 @@ loader.  As a result, @code{interrupt-process}, and other 
related
 functions will work correctly, but using the process ID returned by
 @code{process-id} for other purposes will not.
 
+  One side effect of the mechanism by which process tracing is carried
+out is that job control facilities will not be able to stop
+subprocesses, and the @code{SIGSTOP} signal will appear to have no
+effect.
+
   In addition, Android 12 also terminates subprocesses which are
 consuming CPU while Emacs itself is in the background.  The system
 determines which processes are consuming too much CPU in intervals of
diff --git a/exec/exec.c b/exec/exec.c
index 17051428658..a15386b51bb 100644
--- a/exec/exec.c
+++ b/exec/exec.c
@@ -961,52 +961,68 @@ exec_0 (char *name, struct exec_tracee *tracee,
   ssize_t link_size;
   size_t remaining;
 
-  /* If name is not absolute, then make it relative to TRACEE's
-     cwd.  Use stpcpy, as sprintf is not reentrant.  */
+  /* If the process is trying to run /proc/self/exe, make it run
+     itself instead.  */
 
-  if (name[0] && name[0] != '/')
+  if (!strcmp (name, "/proc/self/exe") && tracee->exec_file)
     {
-      /* Clear `buffer'.  */
-      memset (buffer, 0, sizeof buffer);
-      memset (buffer1, 0, sizeof buffer);
+      strncpy (name, tracee->exec_file, PATH_MAX - 1);
+      name[PATH_MAX] = '\0';
+    }
+  else
+    {
+      /* If name is not absolute, then make it relative to TRACEE's
+        cwd.  Use stpcpy, as sprintf is not reentrant.  */
 
-      /* Copy over /proc, the PID, and /cwd/.  */
-      rewrite = stpcpy (buffer, "/proc/");
-      rewrite = format_pid (rewrite, tracee->pid);
-      stpcpy (rewrite, "/cwd");
+      if (name[0] && name[0] != '/')
+       {
+         /* Clear `buffer'.  */
+         memset (buffer, 0, sizeof buffer);
+         memset (buffer1, 0, sizeof buffer);
 
-      /* Resolve this symbolic link.  */
+         /* Copy over /proc, the PID, and /cwd/.  */
+         rewrite = stpcpy (buffer, "/proc/");
+         rewrite = format_pid (rewrite, tracee->pid);
+         stpcpy (rewrite, "/cwd");
 
-      link_size = readlink (buffer, buffer1,
-                           PATH_MAX + 1);
+         /* Resolve this symbolic link.  */
 
-      if (link_size < 0)
-       return NULL;
+         link_size = readlink (buffer, buffer1,
+                               PATH_MAX + 1);
 
-      /* Check that the name is a reasonable size.  */
+         if (link_size < 0)
+           return NULL;
 
-      if (link_size > PATH_MAX)
-       {
-         /* The name is too long.  */
-         errno = ENAMETOOLONG;
-         return NULL;
-       }
+         /* Check that the name is a reasonable size.  */
+
+         if (link_size > PATH_MAX)
+           {
+             /* The name is too long.  */
+             errno = ENAMETOOLONG;
+             return NULL;
+           }
 
-      /* Add a directory separator if necessary.  */
+         /* Add a directory separator if necessary.  */
       
-      if (!link_size || buffer1[link_size - 1] != '/')
-       buffer1[link_size] = '/', link_size++;
+         if (!link_size || buffer1[link_size - 1] != '/')
+           buffer1[link_size] = '/', link_size++;
 
-      rewrite = buffer1 + link_size;
-      remaining = buffer1 + sizeof buffer1 - rewrite - 1;
-      rewrite = stpncpy (rewrite, name, remaining);
+         rewrite = buffer1 + link_size;
+         remaining = buffer1 + sizeof buffer1 - rewrite - 1;
+         rewrite = stpncpy (rewrite, name, remaining);
 
-      /* Replace name with buffer1.  */
+         /* Replace name with buffer1.  */
 #ifndef REENTRANT
-      strcpy (name, buffer1);
+         strcpy (name, buffer1);
 #endif /* REENTRANT */
+       }
     }
 
+  /* Check that the file is accessible and executable.  */
+
+  if (access (name, X_OK))
+    return NULL;
+
   fd = open (name, O_RDONLY);
   if (fd < 0)
     return NULL;



reply via email to

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