summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Nguyen <olivernguyen@google.com>2019-06-05 14:19:22 -0700
committerandroid-build-merger <android-build-merger@google.com>2019-06-05 14:19:22 -0700
commitcc1b0fba71b55dabf3a3a5d4d4f6e5c806b7db6c (patch)
tree2caae05c541f7d426da27bdb9f674d6467c47dcb
parente9ddbdf4a8dadec90a29b33fba663901563a2e17 (diff)
parent5c1ad00d4b827e07a4d18ea686f21bb6cf5cc8c6 (diff)
downloadextras-cc1b0fba71b55dabf3a3a5d4d4f6e5c806b7db6c.tar.gz
Merge "Do not create property_watch_loop thread for zygote" into qt-dev
am: 5c1ad00d4b Change-Id: Idb1e40982b8aa0edd6e6f40b4f53d1793a6a8efb
-rw-r--r--toolchain-extras/profile-extras.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/toolchain-extras/profile-extras.cpp b/toolchain-extras/profile-extras.cpp
index 1b1393b7..2d685084 100644
--- a/toolchain-extras/profile-extras.cpp
+++ b/toolchain-extras/profile-extras.cpp
@@ -17,7 +17,9 @@
#include <errno.h>
#include <pthread.h>
#include <signal.h>
+#include <stdlib.h>
#include <string.h>
+#include <libgen.h> // For POSIX basename().
// Use _system_properties.h to use __system_property_wait_any()
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
@@ -84,6 +86,20 @@ __attribute__((constructor)) int init_profile_extras(void) {
return -1;
}
+ // Do not create thread running property_watch_loop for zygote (it can get
+ // invoked as zygote or app_process). This check is only needed for the
+ // platform, but can be done on any version after Android L, when
+ // getprogname() was added.
+#if defined(__ANDROID_API__) && __ANDROID_API__ >= __ANDROID_API_L__
+ const char *prog_basename = basename(getprogname());
+ if (strncmp(prog_basename, "zygote", strlen("zygote")) == 0) {
+ return 0;
+ }
+ if (strncmp(prog_basename, "app_process", strlen("app_process")) == 0) {
+ return 0;
+ }
+#endif
+
pthread_t thread;
int error = pthread_create(&thread, nullptr, property_watch_loop, nullptr);
if (error != 0) {