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: ea595ba2a0 ("init: Log more information if stopping times out")
Change-Id: I3c882c364f11278087a78efb7a8e8fee8e582417
Signed-off-by: Bart Van Assche <bvanassche@google.com>
This commit is contained in:
Bart Van Assche 2023-11-01 14:29:07 -07:00
parent 4844092066
commit 7ce6453aa8

View file

@ -139,10 +139,10 @@ void WaitToBeReaped(const std::vector<pid_t>& pids, std::chrono::milliseconds ti
}
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;
}
}