mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-01 08:17:38 +00:00
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.
This commit is contained in:
parent
fa821ed186
commit
797c30b7ab
@ -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 ();
|
||||
}
|
||||
};
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
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 @@ invocation of app_process (through android-emacs) can
|
||||
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)
|
||||
{
|
||||
|
@ -261,6 +261,14 @@ void *unused_pointer;
|
||||
|
||||
#endif /* __i386__ */
|
||||
|
||||
/* Whether or not the default signal mask has been changed. If so,
|
||||
the signal mask must be restored before calling
|
||||
android_emacs_init. */
|
||||
static bool signal_mask_changed_p;
|
||||
|
||||
/* The signal mask at the time Emacs was started. */
|
||||
static sigset_t startup_signal_mask;
|
||||
|
||||
|
||||
|
||||
/* Event handling functions. Events are stored on a (circular) queue
|
||||
@ -2562,7 +2570,15 @@ NATIVE_NAME (initEmacs) (JNIEnv *env, jobject object, jarray argv,
|
||||
ANDROID_DELETE_LOCAL_REF (argv);
|
||||
ANDROID_DELETE_LOCAL_REF (dump_file_object);
|
||||
|
||||
/* Restore the signal mask at the time of startup if it was changed
|
||||
to block unwanted signals from reaching system threads. */
|
||||
|
||||
if (signal_mask_changed_p)
|
||||
pthread_sigmask (SIG_SETMASK, &startup_signal_mask, NULL);
|
||||
|
||||
/* Now start Emacs proper. */
|
||||
android_emacs_init (nelements, c_argv, dump_file);
|
||||
|
||||
/* android_emacs_init should never return. */
|
||||
emacs_abort ();
|
||||
}
|
||||
@ -3128,9 +3144,14 @@ NATIVE_NAME (setupSystemThread) (void)
|
||||
sigdelset (&sigset, SIGSEGV);
|
||||
sigdelset (&sigset, SIGBUS);
|
||||
|
||||
if (pthread_sigmask (SIG_BLOCK, &sigset, NULL))
|
||||
/* Save the signal mask that was previously used. It will be
|
||||
restored in `initEmacs'. */
|
||||
|
||||
if (pthread_sigmask (SIG_BLOCK, &sigset, &startup_signal_mask))
|
||||
__android_log_print (ANDROID_LOG_WARN, __func__,
|
||||
"pthread_sigmask: %s", strerror (errno));
|
||||
else
|
||||
signal_mask_changed_p = true;
|
||||
}
|
||||
|
||||
#ifdef __clang__
|
||||
|
Loading…
Reference in New Issue
Block a user