From 6d5b7f7303580945479132520122e03bcd5a3044 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 (cherry picked from commit c78ae6008713ab2a1d64d0831ac9e139ed49ae10) Bug: 189250652 Merged-In: Icccf60d0ad4439d702f36ace31abe092df1c69c2 --- Process.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Process.cpp b/Process.cpp index 277d6a3..c23d887 100644 --- a/Process.cpp +++ b/Process.cpp @@ -169,7 +169,15 @@ int KillProcessesWithOpenFiles(const std::string& prefix, int signal) { } 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); } }