Send SIGKILL to kill the child.
PostinstallRunnerActionTest.RunAsRootCancelPostinstallActionTest wasn't able
to kill the child in brilloemulator because it send a SIGTERM to the child
before the child exec, and the SIGTERM was ignored.
So we instead send a SIGKILL to kill the child which won't be ignored.
Test: adb -s emulator-5554 shell /data/nativetest/update_engine_unittests/update_engine_unittests
Bug: 28319454
Change-Id: Ideb10fe1f7a41ad11522f5d1b53d952a82f9508f
diff --git a/common/subprocess.cc b/common/subprocess.cc
index 53cccff..4e6d352 100644
--- a/common/subprocess.cc
+++ b/common/subprocess.cc
@@ -213,8 +213,10 @@
if (pid_record == subprocess_records_.end())
return;
pid_record->second->callback.Reset();
- if (kill(pid, SIGTERM) != 0) {
- PLOG(WARNING) << "Error sending SIGTERM to " << pid;
+ // We don't care about output/return code, so we use SIGKILL here to ensure it
+ // will be killed, SIGTERM might lead to leaked subprocess.
+ if (kill(pid, SIGKILL) != 0) {
+ PLOG(WARNING) << "Error sending SIGKILL to " << pid;
}
// Release the pid now so we don't try to kill it if Subprocess is destroyed
// before the corresponding ChildExitedCallback() is called.