Implement susped, resume and cancel for the Postinstall action.

This patch sends SIGSTOP/SIGCONT to the running postinstall program to
suspend/resume the child process, and SIGKILL when cancelling it.

Bug: 27272144
TEST=Added unittest to check the signal being sent.

(cherry picked from commit d15c546ed794293d0a63770467a0f3c4c84c6214)

Change-Id: Ie99b406b4d7f73dda4189b7a5a7d627c866055d6
diff --git a/common/subprocess.cc b/common/subprocess.cc
index f43aaac..61f2d54 100644
--- a/common/subprocess.cc
+++ b/common/subprocess.cc
@@ -207,7 +207,12 @@
   if (pid_record == subprocess_records_.end())
     return;
   pid_record->second->callback.Reset();
-  kill(pid, SIGTERM);
+  if (kill(pid, SIGTERM) != 0) {
+    PLOG(WARNING) << "Error sending SIGTERM to " << pid;
+  }
+  // Release the pid now so we don't try to kill it if Subprocess is destroyed
+  // before the corresponding ChildExitedCallback() is called.
+  pid_record->second->proc.Release();
 }
 
 bool Subprocess::SynchronousExec(const vector<string>& cmd,