summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/org/gnu/emacs/EmacsNative.java4
-rw-r--r--java/org/gnu/emacs/EmacsService.java25
2 files changed, 29 insertions, 0 deletions
diff --git a/java/org/gnu/emacs/EmacsNative.java b/java/org/gnu/emacs/EmacsNative.java
index cb89cf6808a..2fcbf8b94ef 100644
--- a/java/org/gnu/emacs/EmacsNative.java
+++ b/java/org/gnu/emacs/EmacsNative.java
@@ -188,6 +188,10 @@ public final class EmacsNative
KEYCODE_VOLUME_MUTE should be forwarded to Emacs. */
public static native boolean shouldForwardMultimediaButtons ();
+ /* Initialize the current thread, by blocking signals that do not
+ interest it. */
+ public static native void setupSystemThread ();
+
/* Input connection functions. These mostly correspond to their
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)
{