From c78ae6008713ab2a1d64d0831ac9e139ed49ae10 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Wed, 5 May 2021 12:11:33 -0700 Subject: [PATCH] Show names of processes killed by KillProcessesWithOpenFiles() Otherwise only the pids are shown, and it's hard to tell which processes actually got killed. Bug: 187231646 Change-Id: Icccf60d0ad4439d702f36ace31abe092df1c69c2 --- Process.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Process.cpp b/Process.cpp index 79fe15d..c1d55ee 100644 --- a/Process.cpp +++ b/Process.cpp @@ -175,7 +175,15 @@ int KillProcessesWithOpenFiles(const std::string& prefix, int signal, bool killF } if (signal != 0) { for (const auto& pid : pids) { - LOG(WARNING) << "Sending " << strsignal(signal) << " to " << pid; + std::string comm; + android::base::ReadFileToString(StringPrintf("/proc/%d/comm", pid), &comm); + comm = android::base::Trim(comm); + + std::string exe; + android::base::Readlink(StringPrintf("/proc/%d/exe", pid), &exe); + + LOG(WARNING) << "Sending " << strsignal(signal) << " to pid " << pid << " (" << comm + << ", " << exe << ")"; kill(pid, signal); } }