init: Fix a bug in the WaitToBeReaped() logging code
Only report status information for the processes that are still running.
Additionally, make the logging output look better by starting the
process information from /proc start on a new line.
Fixes: ea595ba2a05a ("init: Log more information if stopping times out")
Change-Id: I3c882c364f11278087a78efb7a8e8fee8e582417
Signed-off-by: Bart Van Assche <bvanassche@google.com>
diff --git a/init/sigchld_handler.cpp b/init/sigchld_handler.cpp
index f8c501f..0901a96 100644
--- a/init/sigchld_handler.cpp
+++ b/init/sigchld_handler.cpp
@@ -139,10 +139,10 @@
}
LOG(INFO) << "Waiting for " << pids.size() << " pids to be reaped took " << t << " with "
<< alive_pids.size() << " of them still running";
- for (pid_t pid : pids) {
+ for (pid_t pid : alive_pids) {
std::string status = "(no-such-pid)";
ReadFileToString(StringPrintf("/proc/%d/status", pid), &status);
- LOG(INFO) << "Still running: " << pid << ' ' << status;
+ LOG(INFO) << "Still running: " << pid << '\n' << status;
}
}