From a8a56c8bd120dabfad492a8c6dbfcbefc3702559 Mon Sep 17 00:00:00 2001 From: Kweku Adams Date: Mon, 23 Apr 2018 06:15:31 -0700 Subject: [PATCH] Preventing zombie process creation. Bug: 78363774 Test: flash device, run 'adb shell incident', then check 'adb shell ps | grep incidentd' Change-Id: I473894eb1c05ce8557da846d1ccdcbfa672356eb --- cmds/incidentd/src/Section.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmds/incidentd/src/Section.cpp b/cmds/incidentd/src/Section.cpp index 93875cde4e24e..0e72fc0768fd9 100644 --- a/cmds/incidentd/src/Section.cpp +++ b/cmds/incidentd/src/Section.cpp @@ -902,11 +902,16 @@ status_t TombstoneSection::BlockingCall(int pipeWriteFd) const { // Read from the pipe concurrently to avoid blocking the child. FdBuffer buffer; err = buffer.readFully(dumpPipe.readFd().get()); + // Wait on the child to avoid it becoming a zombie process. + status_t cStatus = wait_child(child); if (err != NO_ERROR) { ALOGW("TombstoneSection '%s' failed to read stack dump: %d", this->name.string(), err); dumpPipe.readFd().reset(); break; } + if (cStatus != NO_ERROR) { + ALOGE("TombstoneSection '%s' child had an issue: %s\n", this->name.string(), strerror(-cStatus)); + } auto dump = std::make_unique(buffer.size()); auto iterator = buffer.data();