summaryrefslogtreecommitdiff
path: root/cmds/screencap/screencap.cpp
diff options
context:
space:
mode:
authorMartijn Coenen <maco@google.com>2017-07-24 09:19:26 +0200
committerMartijn Coenen <maco@google.com>2017-08-04 07:31:09 +0000
commit48b7408201bd4614b75a4713e5104b9eee9a1cbe (patch)
treea247211d34ec8c474cb7cda340f02f87d97dd271 /cmds/screencap/screencap.cpp
parent5a800cf0692758489367247d36e5ceb29004eb01 (diff)
screencap: always exit with _exit().
Delay starting the threadpool until necessary, and once started, always exit with _exit(). Bug: 36066697 Bug: 62956201 Test: mma, screencap -p Merged-In: I0b9ab542f6434f57b498cd7dc41219ef57e36721 Change-Id: I0b9ab542f6434f57b498cd7dc41219ef57e36721 (cherry picked from commit 4d125c1df6b7e4dbc3a788ecce5434970e676b06) Change-Id: Ie79ead94c62df0c4057d7fc6735abe9dcd1e940f
Diffstat (limited to 'cmds/screencap/screencap.cpp')
-rw-r--r--cmds/screencap/screencap.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/cmds/screencap/screencap.cpp b/cmds/screencap/screencap.cpp
index 23668786abee..35f8bbb57e50 100644
--- a/cmds/screencap/screencap.cpp
+++ b/cmds/screencap/screencap.cpp
@@ -116,13 +116,6 @@ static status_t notifyMediaScanner(const char* fileName) {
int main(int argc, char** argv)
{
- // setThreadPoolMaxThreadCount(0) actually tells the kernel it's
- // not allowed to spawn any additional threads, but we still spawn
- // a binder thread from userspace when we call startThreadPool().
- // See b/36066697 for rationale
- ProcessState::self()->setThreadPoolMaxThreadCount(0);
- ProcessState::self()->startThreadPool();
-
const char* pname = argv[0];
bool png = false;
int32_t displayId = DEFAULT_DISPLAY_ID;
@@ -182,11 +175,19 @@ int main(int argc, char** argv)
ISurfaceComposer::eRotate90, // 3 == DISPLAY_ORIENTATION_270
};
+ // setThreadPoolMaxThreadCount(0) actually tells the kernel it's
+ // not allowed to spawn any additional threads, but we still spawn
+ // a binder thread from userspace when we call startThreadPool().
+ // See b/36066697 for rationale
+ ProcessState::self()->setThreadPoolMaxThreadCount(0);
+ ProcessState::self()->startThreadPool();
+
ScreenshotClient screenshot;
sp<IBinder> display = SurfaceComposerClient::getBuiltInDisplay(displayId);
if (display == NULL) {
fprintf(stderr, "Unable to get handle for display %d\n", displayId);
- return 1;
+ // b/36066697: Avoid running static destructors.
+ _exit(1);
}
Vector<DisplayInfo> configs;
@@ -195,7 +196,8 @@ int main(int argc, char** argv)
if (static_cast<size_t>(activeConfig) >= configs.size()) {
fprintf(stderr, "Active config %d not inside configs (size %zu)\n",
activeConfig, configs.size());
- return 1;
+ // b/36066697: Avoid running static destructors.
+ _exit(1);
}
uint8_t displayOrientation = configs[activeConfig].orientation;
uint32_t captureOrientation = ORIENTATION_MAP[displayOrientation];