Merge "Use logical path to handle different dm target per boot" into main
diff --git a/Process.cpp b/Process.cpp
index c1d55ee..426a425 100644
--- a/Process.cpp
+++ b/Process.cpp
@@ -173,6 +173,7 @@
             }
         }
     }
+    int totalKilledPids = pids.size();
     if (signal != 0) {
         for (const auto& pid : pids) {
             std::string comm;
@@ -184,10 +185,17 @@
 
             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