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.
Change-Id: Iebe9bd34448ad1d0a5340c82e1fd839ff8c69dd2
diff --git a/payload_consumer/postinstall_runner_action.h b/payload_consumer/postinstall_runner_action.h
index 08dedd2..a626ce6 100644
--- a/payload_consumer/postinstall_runner_action.h
+++ b/payload_consumer/postinstall_runner_action.h
@@ -34,10 +34,11 @@
explicit PostinstallRunnerAction(BootControlInterface* boot_control)
: PostinstallRunnerAction(boot_control, nullptr) {}
+ // InstallPlanAction overrides.
void PerformAction() override;
-
- // Note that there's no support for terminating this action currently.
- void TerminateProcessing() override { CHECK(false); }
+ void SuspendAction() override;
+ void ResumeAction() override;
+ void TerminateProcessing() override;
// Debugging/logging
static std::string StaticType() { return "PostinstallRunnerAction"; }
@@ -54,6 +55,9 @@
void PerformPartitionPostinstall();
+ // Unmount and remove the mountpoint directory if needed.
+ void CleanupMount();
+
// Subprocess::Exec callback.
void CompletePartitionPostinstall(int return_code,
const std::string& output);
@@ -82,6 +86,9 @@
// file name; used for testing.
const char* powerwash_marker_file_;
+ // Postinstall command currently running, or 0 if no program running.
+ pid_t current_command_{0};
+
DISALLOW_COPY_AND_ASSIGN(PostinstallRunnerAction);
};