diff options
| author | Po Lu | 2023-06-09 14:03:50 +0800 |
|---|---|---|
| committer | Po Lu | 2023-06-09 14:03:50 +0800 |
| commit | c321eea5af535d102c5e1d2d7e95029ce6fee427 (patch) | |
| tree | efd19f5c11d2bf426c196ab97403aa1d58e223b9 /src | |
| parent | 7f073df53374bc1b96ac07e949af11b8af06b94b (diff) | |
| download | emacs-c321eea5af535d102c5e1d2d7e95029ce6fee427.tar.gz emacs-c321eea5af535d102c5e1d2d7e95029ce6fee427.zip | |
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 'src')
| -rw-r--r-- | src/android.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/android.c b/src/android.c index 92aab548180..681723124ee 100644 --- a/src/android.c +++ b/src/android.c | |||
| @@ -3077,6 +3077,30 @@ NATIVE_NAME (answerQuerySpin) (JNIEnv *env, jobject object) | |||
| 3077 | android_answer_query_spin (); | 3077 | android_answer_query_spin (); |
| 3078 | } | 3078 | } |
| 3079 | 3079 | ||
| 3080 | |||
| 3081 | |||
| 3082 | /* System thread setup. Android doesn't always block signals Emacs is | ||
| 3083 | interested in from being received by the UI or render threads, | ||
| 3084 | which can lead to problems when those signals then interrupt one of | ||
| 3085 | those threads. */ | ||
| 3086 | |||
| 3087 | JNIEXPORT void JNICALL | ||
| 3088 | NATIVE_NAME (setupSystemThread) (void) | ||
| 3089 | { | ||
| 3090 | sigset_t sigset; | ||
| 3091 | |||
| 3092 | /* Block everything except for SIGSEGV and SIGBUS; those two are | ||
| 3093 | used by the runtime. */ | ||
| 3094 | |||
| 3095 | sigfillset (&sigset); | ||
| 3096 | sigaddset (&sigset, SIGSEGV); | ||
| 3097 | sigaddset (&sigset, SIGBUS); | ||
| 3098 | |||
| 3099 | if (pthread_sigmask (SIG_BLOCK, &sigset, NULL)) | ||
| 3100 | __android_log_print (ANDROID_LOG_WARN, __func__, | ||
| 3101 | "pthread_sigmask: %s", strerror (errno)); | ||
| 3102 | } | ||
| 3103 | |||
| 3080 | #ifdef __clang__ | 3104 | #ifdef __clang__ |
| 3081 | #pragma clang diagnostic pop | 3105 | #pragma clang diagnostic pop |
| 3082 | #else | 3106 | #else |