summaryrefslogtreecommitdiff
path: root/java/org/gnu/emacs/EmacsService.java
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2023-06-09 14:03:50 +0800
committerPo Lu <luangruo@yahoo.com>2023-06-09 14:03:50 +0800
commitc321eea5af535d102c5e1d2d7e95029ce6fee427 (patch)
treeefd19f5c11d2bf426c196ab97403aa1d58e223b9 /java/org/gnu/emacs/EmacsService.java
parent7f073df53374bc1b96ac07e949af11b8af06b94b (diff)
Block profiling signals in the Android UI thread
* java/org/gnu/emacs/EmacsNative.java (EmacsNative): New function `setupSystemThread'. * java/org/gnu/emacs/EmacsService.java (onCreate): Block all signals except for SIGBUS and SIGSEGV in the UI thread. * src/android.c (setupSystemThread): New function.
Diffstat (limited to 'java/org/gnu/emacs/EmacsService.java')
-rw-r--r--java/org/gnu/emacs/EmacsService.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/java/org/gnu/emacs/EmacsService.java b/java/org/gnu/emacs/EmacsService.java
index 48e39f8b355..96216e51cf4 100644
--- a/java/org/gnu/emacs/EmacsService.java
+++ b/java/org/gnu/emacs/EmacsService.java
@@ -25,6 +25,7 @@ import java.io.UnsupportedEncodingException;
import java.util.List;
+import java.util.concurrent.Semaphore;
import java.util.concurrent.atomic.AtomicInteger;
import android.graphics.Matrix;
@@ -211,6 +212,7 @@ public final class EmacsService extends Service
final String filesDir, libDir, cacheDir, classPath;
final double pixelDensityX;
final double pixelDensityY;
+ final Semaphore signalSemaphore;
SERVICE = this;
handler = new Handler (Looper.getMainLooper ());
@@ -220,6 +222,7 @@ public final class EmacsService extends Service
pixelDensityX = metrics.xdpi;
pixelDensityY = metrics.ydpi;
resolver = getContentResolver ();
+ signalSemaphore = new Semaphore (0);
try
{
@@ -248,11 +251,33 @@ public final class EmacsService extends Service
cacheDir, (float) pixelDensityX,
(float) pixelDensityY,
classPath, EmacsService.this);
+
+ /* Wait for the signal mask to be set up in the UI
+ thread. */
+
+ while (true)
+ {
+ try
+ {
+ signalSemaphore.acquire ();
+ break;
+ }
+ catch (InterruptedException e)
+ {
+ ;;
+ }
+ }
}
}, extraStartupArgument,
/* If any file needs to be opened, open it now. */
EmacsOpenActivity.fileToOpen);
thread.start ();
+
+ /* Now that the thread has been started, block signals which
+ don't interest the current thread. */
+
+ EmacsNative.setupSystemThread ();
+ signalSemaphore.release ();
}
catch (IOException exception)
{