diff options
| author | Po Lu | 2024-02-12 11:16:47 +0800 |
|---|---|---|
| committer | Po Lu | 2024-02-12 11:55:01 +0800 |
| commit | bc6c55c5cf3fc5bd248232c6332ea7cca19ffe91 (patch) | |
| tree | c831ac6e0d8b26be2e24e330ec021bff2e61af1b /src/androidfns.c | |
| parent | 57544fa2a2e1f2d04aa6b6bdf49bde71141b945d (diff) | |
| download | emacs-bc6c55c5cf3fc5bd248232c6332ea7cca19ffe91.tar.gz emacs-bc6c55c5cf3fc5bd248232c6332ea7cca19ffe91.zip | |
Disable exec loader when Emacs is running under an existing instance
* src/androidfns.c (syms_of_androidfns_for_pdumper): Check if
Emacs is running under process tracing, and if so, disable
android_use_exec_loader.
Diffstat (limited to 'src/androidfns.c')
| -rw-r--r-- | src/androidfns.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/androidfns.c b/src/androidfns.c index 48c3f3046d6..ea3d5f71c7c 100644 --- a/src/androidfns.c +++ b/src/androidfns.c | |||
| @@ -3216,6 +3216,10 @@ syms_of_androidfns_for_pdumper (void) | |||
| 3216 | jstring string; | 3216 | jstring string; |
| 3217 | Lisp_Object language, country, script, variant; | 3217 | Lisp_Object language, country, script, variant; |
| 3218 | const char *data; | 3218 | const char *data; |
| 3219 | FILE *fd; | ||
| 3220 | char *line; | ||
| 3221 | size_t size; | ||
| 3222 | long pid; | ||
| 3219 | 3223 | ||
| 3220 | /* Find the Locale class. */ | 3224 | /* Find the Locale class. */ |
| 3221 | 3225 | ||
| @@ -3386,6 +3390,35 @@ syms_of_androidfns_for_pdumper (void) | |||
| 3386 | 3390 | ||
| 3387 | /* Set Vandroid_os_language. */ | 3391 | /* Set Vandroid_os_language. */ |
| 3388 | Vandroid_os_language = list4 (language, country, script, variant); | 3392 | Vandroid_os_language = list4 (language, country, script, variant); |
| 3393 | |||
| 3394 | /* Detect whether Emacs is running under libloader.so or another | ||
| 3395 | process tracing mechanism, and disable `android_use_exec_loader' if | ||
| 3396 | so, leaving subprocesses started by Emacs to the care of that | ||
| 3397 | loader instance. */ | ||
| 3398 | |||
| 3399 | if (android_get_current_api_level () >= 29) /* Q */ | ||
| 3400 | { | ||
| 3401 | fd = fopen ("/proc/self/status", "r"); | ||
| 3402 | if (!fd) | ||
| 3403 | return; | ||
| 3404 | |||
| 3405 | line = NULL; | ||
| 3406 | while (getline (&line, &size, fd) != -1) | ||
| 3407 | { | ||
| 3408 | if (strncmp (line, "TracerPid:", sizeof "TracerPid:" - 1)) | ||
| 3409 | continue; | ||
| 3410 | |||
| 3411 | pid = atol (line + sizeof "TracerPid:" - 1); | ||
| 3412 | |||
| 3413 | if (pid) | ||
| 3414 | android_use_exec_loader = false; | ||
| 3415 | |||
| 3416 | break; | ||
| 3417 | } | ||
| 3418 | |||
| 3419 | free (line); | ||
| 3420 | fclose (fd); | ||
| 3421 | } | ||
| 3389 | } | 3422 | } |
| 3390 | 3423 | ||
| 3391 | #endif /* ANDROID_STUBIFY */ | 3424 | #endif /* ANDROID_STUBIFY */ |