Merge "Verify if pid actually killed for processes with open files" into main am: ef22c8f122
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2806219 Change-Id: I0b4d38161da10dfa2532931e58bbe13164c8073a Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
f97bb9485e
1 changed files with 10 additions and 2 deletions
12
Process.cpp
12
Process.cpp
|
@ -173,6 +173,7 @@ int KillProcessesWithOpenFiles(const std::string& prefix, int signal, bool killF
|
|||
}
|
||||
}
|
||||
}
|
||||
int totalKilledPids = pids.size();
|
||||
if (signal != 0) {
|
||||
for (const auto& pid : pids) {
|
||||
std::string comm;
|
||||
|
@ -184,10 +185,17 @@ int KillProcessesWithOpenFiles(const std::string& prefix, int signal, bool killF
|
|||
|
||||
LOG(WARNING) << "Sending " << strsignal(signal) << " to pid " << pid << " (" << comm
|
||||
<< ", " << exe << ")";
|
||||
kill(pid, signal);
|
||||
if (kill(pid, signal) < 0) {
|
||||
if (errno == ESRCH) {
|
||||
totalKilledPids--;
|
||||
LOG(WARNING) << "The target pid " << pid << " was already killed";
|
||||
continue;
|
||||
}
|
||||
LOG(ERROR) << "Unable to send signal " << strsignal(signal) << " to pid " << pid;
|
||||
}
|
||||
}
|
||||
return pids.size();
|
||||
}
|
||||
return totalKilledPids;
|
||||
}
|
||||
|
||||
} // namespace vold
|
||||
|
|
Loading…
Reference in a new issue