From 797c30b7abc165d5ebe65474c7398ccad0e3023c Mon Sep 17 00:00:00 2001 From: Po Lu Date: Sat, 17 Jun 2023 12:07:40 +0800 Subject: Initialize signal mask earlier * java/org/gnu/emacs/EmacsService.java (onCreate, run): Don't initialize signal mask here. * java/org/gnu/emacs/EmacsApplication.java (onCreate): Do it here instead. * src/android.c (JNICALL): Restore previous signal masks. --- java/org/gnu/emacs/EmacsApplication.java | 8 ++++++++ java/org/gnu/emacs/EmacsService.java | 25 ------------------------- 2 files changed, 8 insertions(+), 25 deletions(-) (limited to 'java') diff --git a/java/org/gnu/emacs/EmacsApplication.java b/java/org/gnu/emacs/EmacsApplication.java index d8b77acdf9e..8afa5bcedb4 100644 --- a/java/org/gnu/emacs/EmacsApplication.java +++ b/java/org/gnu/emacs/EmacsApplication.java @@ -78,7 +78,15 @@ public final class EmacsApplication extends Application public void onCreate () { + /* Block signals which don't interest the current thread and its + descendants created by the system. The original signal mask + will be restored for the Emacs thread in `initEmacs'. */ + EmacsNative.setupSystemThread (); + + /* Locate a suitable dump file. */ findDumpFile (this); + + /* Start the rest of the application. */ super.onCreate (); } }; diff --git a/java/org/gnu/emacs/EmacsService.java b/java/org/gnu/emacs/EmacsService.java index 2fe4e8c4146..820befb52d2 100644 --- a/java/org/gnu/emacs/EmacsService.java +++ b/java/org/gnu/emacs/EmacsService.java @@ -25,7 +25,6 @@ import java.io.UnsupportedEncodingException; import java.util.List; -import java.util.concurrent.Semaphore; import java.util.concurrent.atomic.AtomicInteger; import android.graphics.Matrix; @@ -212,7 +211,6 @@ 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 ()); @@ -222,7 +220,6 @@ public final class EmacsService extends Service pixelDensityX = metrics.xdpi; pixelDensityY = metrics.ydpi; resolver = getContentResolver (); - signalSemaphore = new Semaphore (0); try { @@ -251,33 +248,11 @@ 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) { -- cgit v1.2.1