blob: d51241f25783597dacfe8eecbaaf7a70e4c6b8d7 [file] [log] [blame]
Alex Deymoaea4c1c2015-08-19 20:24:43 -07001//
2// Copyright (C) 2011 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
adlr@google.com3defe6a2009-12-04 20:57:17 +000016
Alex Deymo39910dc2015-11-09 17:04:30 -080017#include "update_engine/payload_consumer/postinstall_runner_action.h"
Jay Srinivasan1c0fe792013-03-28 16:45:25 -070018
Alex Deymo0d298542016-03-30 18:31:49 -070019#include <fcntl.h>
Alex Deymod15c5462016-03-09 18:11:12 -080020#include <signal.h>
adlr@google.com3defe6a2009-12-04 20:57:17 +000021#include <stdlib.h>
Alex Vakulenko44cab302014-07-23 13:12:15 -070022#include <sys/mount.h>
Alex Deymod15c5462016-03-09 18:11:12 -080023#include <sys/types.h>
Alex Deymo0d298542016-03-30 18:31:49 -070024#include <unistd.h>
Jay Srinivasan1c0fe792013-03-28 16:45:25 -070025
Alex Deymo44b35672016-04-05 17:57:48 -070026#include <cmath>
27
Alex Deymoe5e5fe92015-10-05 09:28:19 -070028#include <base/files/file_path.h>
29#include <base/files/file_util.h>
Alex Deymod15c5462016-03-09 18:11:12 -080030#include <base/logging.h>
hscham00b6aa22020-02-20 12:32:06 +090031#include <base/stl_util.h>
Alex Deymo0d298542016-03-30 18:31:49 -070032#include <base/strings/string_split.h>
Alex Deymo390efed2016-02-18 11:00:40 -080033#include <base/strings/string_util.h>
Alex Deymo461b2592015-07-24 20:10:52 -070034
Alex Deymo39910dc2015-11-09 17:04:30 -080035#include "update_engine/common/action_processor.h"
Alex Deymob15a0b82015-11-25 20:30:40 -030036#include "update_engine/common/boot_control_interface.h"
Alex Deymo14dbd332016-03-01 18:55:54 -080037#include "update_engine/common/platform_constants.h"
Alex Deymo39910dc2015-11-09 17:04:30 -080038#include "update_engine/common/subprocess.h"
39#include "update_engine/common/utils.h"
adlr@google.com3defe6a2009-12-04 20:57:17 +000040
Alex Deymo0d298542016-03-30 18:31:49 -070041namespace {
42
43// The file descriptor number from the postinstall program's perspective where
44// it can report status updates. This can be any number greater than 2 (stderr),
45// but must be kept in sync with the "bin/postinst_progress" defined in the
46// sample_images.sh file.
47const int kPostinstallStatusFd = 3;
48
49} // namespace
50
adlr@google.com3defe6a2009-12-04 20:57:17 +000051namespace chromeos_update_engine {
52
Alex Deymo0d298542016-03-30 18:31:49 -070053using brillo::MessageLoop;
adlr@google.com3defe6a2009-12-04 20:57:17 +000054using std::string;
Andrew de los Reyesf9714432010-05-04 10:21:23 -070055using std::vector;
adlr@google.com3defe6a2009-12-04 20:57:17 +000056
adlr@google.com3defe6a2009-12-04 20:57:17 +000057void PostinstallRunnerAction::PerformAction() {
58 CHECK(HasInputObject());
Kelvin Zhang8b1e0dc2020-10-26 12:27:53 -040059 CHECK(boot_control_);
Chris Sosad317e402013-06-12 13:47:09 -070060 install_plan_ = GetInputObject();
Darin Petkov6f03a3b2010-11-10 14:27:14 -080061
Kelvin Zhang8b1e0dc2020-10-26 12:27:53 -040062 auto dynamic_control = boot_control_->GetDynamicPartitionControl();
63 CHECK(dynamic_control);
64
65 // Mount snapshot partitions for Virtual AB Compression Compression.
66 if (dynamic_control->GetVirtualAbCompressionFeatureFlag().IsEnabled()) {
67 // Before calling MapAllPartitions to map snapshot devices, all CowWriters
68 // must be closed, and MapAllPartitions() should be called.
69 dynamic_control->UnmapAllPartitions();
70 if (!dynamic_control->MapAllPartitions()) {
71 return CompletePostinstall(ErrorCode::kPostInstallMountError);
72 }
73 }
74
Zentaro Kavanagh28def4f2019-01-15 17:15:01 -080075 // We always powerwash when rolling back, however policy can determine
76 // if this is a full/normal powerwash, or a special rollback powerwash
77 // that retains a small amount of system state such as enrollment and
78 // network configuration. In both cases all user accounts are deleted.
Marton Hunyady199152d2018-05-07 19:08:48 +020079 if (install_plan_.powerwash_required || install_plan_.is_rollback) {
Miriam Polzeraff72002020-08-27 08:20:39 +020080 if (hardware_->SchedulePowerwash(
81 install_plan_.rollback_data_save_requested)) {
Alex Deymofb905d92016-06-03 19:26:58 -070082 powerwash_scheduled_ = true;
Jay Srinivasan1c0fe792013-03-28 16:45:25 -070083 } else {
Alex Deymoe5e5fe92015-10-05 09:28:19 -070084 return CompletePostinstall(ErrorCode::kPostinstallPowerwashError);
Jay Srinivasan1c0fe792013-03-28 16:45:25 -070085 }
86 }
87
Alex Deymo0d298542016-03-30 18:31:49 -070088 // Initialize all the partition weights.
89 partition_weight_.resize(install_plan_.partitions.size());
90 total_weight_ = 0;
91 for (size_t i = 0; i < install_plan_.partitions.size(); ++i) {
Tianjie Xu087de9d2019-11-01 17:11:22 -070092 auto& partition = install_plan_.partitions[i];
93 if (!install_plan_.run_post_install && partition.postinstall_optional) {
94 partition.run_postinstall = false;
95 LOG(INFO) << "Skipping optional post-install for partition "
96 << partition.name << " according to install plan.";
97 }
98
Alex Deymo0d298542016-03-30 18:31:49 -070099 // TODO(deymo): This code sets the weight to all the postinstall commands,
100 // but we could remember how long they took in the past and use those
101 // values.
Tianjie Xu087de9d2019-11-01 17:11:22 -0700102 partition_weight_[i] = partition.run_postinstall;
Alex Deymo0d298542016-03-30 18:31:49 -0700103 total_weight_ += partition_weight_[i];
104 }
105 accumulated_weight_ = 0;
106 ReportProgress(0);
107
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700108 PerformPartitionPostinstall();
109}
110
111void PostinstallRunnerAction::PerformPartitionPostinstall() {
Alex Deymo390efed2016-02-18 11:00:40 -0800112 if (install_plan_.download_url.empty()) {
113 LOG(INFO) << "Skipping post-install during rollback";
114 return CompletePostinstall(ErrorCode::kSuccess);
115 }
116
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700117 // Skip all the partitions that don't have a post-install step.
118 while (current_partition_ < install_plan_.partitions.size() &&
119 !install_plan_.partitions[current_partition_].run_postinstall) {
120 VLOG(1) << "Skipping post-install on partition "
121 << install_plan_.partitions[current_partition_].name;
122 current_partition_++;
123 }
124 if (current_partition_ == install_plan_.partitions.size())
125 return CompletePostinstall(ErrorCode::kSuccess);
126
127 const InstallPlan::Partition& partition =
128 install_plan_.partitions[current_partition_];
129
Brian Norris7b428f52019-06-26 10:03:35 -0700130 const string mountable_device = partition.target_path;
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700131 if (mountable_device.empty()) {
132 LOG(ERROR) << "Cannot make mountable device from " << partition.target_path;
133 return CompletePostinstall(ErrorCode::kPostinstallRunnerError);
134 }
135
136 // Perform post-install for the current_partition_ partition. At this point we
137 // need to call CompletePartitionPostinstall to complete the operation and
138 // cleanup.
Alex Deymo390efed2016-02-18 11:00:40 -0800139#ifdef __ANDROID__
140 fs_mount_dir_ = "/postinstall";
141#else // __ANDROID__
Sen Jiang371615b2016-04-13 15:54:29 -0700142 base::FilePath temp_dir;
143 TEST_AND_RETURN(base::CreateNewTempDirectory("au_postint_mount", &temp_dir));
144 fs_mount_dir_ = temp_dir.value();
Alex Deymo390efed2016-02-18 11:00:40 -0800145#endif // __ANDROID__
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700146
Alex Deymof4116502017-03-22 17:00:31 -0700147 // Double check that the fs_mount_dir is not busy with a previous mounted
148 // filesystem from a previous crashed postinstall step.
149 if (utils::IsMountpoint(fs_mount_dir_)) {
150 LOG(INFO) << "Found previously mounted filesystem at " << fs_mount_dir_;
151 utils::UnmountFilesystem(fs_mount_dir_);
152 }
153
Alex Deymocbc22742016-03-04 17:53:02 -0800154 base::FilePath postinstall_path(partition.postinstall_path);
155 if (postinstall_path.IsAbsolute()) {
156 LOG(ERROR) << "Invalid absolute path passed to postinstall, use a relative"
157 "path instead: "
158 << partition.postinstall_path;
159 return CompletePostinstall(ErrorCode::kPostinstallRunnerError);
160 }
161
162 string abs_path =
163 base::FilePath(fs_mount_dir_).Append(postinstall_path).value();
Alex Deymo390efed2016-02-18 11:00:40 -0800164 if (!base::StartsWith(
165 abs_path, fs_mount_dir_, base::CompareCase::SENSITIVE)) {
166 LOG(ERROR) << "Invalid relative postinstall path: "
167 << partition.postinstall_path;
168 return CompletePostinstall(ErrorCode::kPostinstallRunnerError);
169 }
170
Alex Deymo5fb356c2016-03-25 18:48:22 -0700171#ifdef __ANDROID__
172 // In Chromium OS, the postinstall step is allowed to write to the block
173 // device on the target image, so we don't mark it as read-only and should
174 // be read-write since we just wrote to it during the update.
175
176 // Mark the block device as read-only before mounting for post-install.
177 if (!utils::SetBlockDeviceReadOnly(mountable_device, true)) {
178 return CompletePartitionPostinstall(
179 1, "Error marking the device " + mountable_device + " read only.");
180 }
181#endif // __ANDROID__
182
Alex Deymo390efed2016-02-18 11:00:40 -0800183 if (!utils::MountFilesystem(mountable_device,
184 fs_mount_dir_,
185 MS_RDONLY,
Alex Deymo14dbd332016-03-01 18:55:54 -0800186 partition.filesystem_type,
187 constants::kPostinstallMountOptions)) {
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700188 return CompletePartitionPostinstall(
189 1, "Error mounting the device " + mountable_device);
190 }
191
Alex Deymo390efed2016-02-18 11:00:40 -0800192 LOG(INFO) << "Performing postinst (" << partition.postinstall_path << " at "
193 << abs_path << ") installed on device " << partition.target_path
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700194 << " and mountable device " << mountable_device;
195
Alex Deymo032e7722014-03-25 17:53:56 -0700196 // Logs the file format of the postinstall script we are about to run. This
197 // will help debug when the postinstall script doesn't match the architecture
198 // of our build.
Alex Deymo390efed2016-02-18 11:00:40 -0800199 LOG(INFO) << "Format file for new " << partition.postinstall_path
200 << " is: " << utils::GetFileFormat(abs_path);
Alex Deymo032e7722014-03-25 17:53:56 -0700201
Darin Petkov6f03a3b2010-11-10 14:27:14 -0800202 // Runs the postinstall script asynchronously to free up the main loop while
203 // it's running.
Alex Deymo0d298542016-03-30 18:31:49 -0700204 vector<string> command = {abs_path};
205#ifdef __ANDROID__
206 // In Brillo and Android, we pass the slot number and status fd.
207 command.push_back(std::to_string(install_plan_.target_slot));
208 command.push_back(std::to_string(kPostinstallStatusFd));
209#else
210 // Chrome OS postinstall expects the target rootfs as the first parameter.
211 command.push_back(partition.target_path);
212#endif // __ANDROID__
213
214 current_command_ = Subprocess::Get().ExecFlags(
Alex Deymod15c5462016-03-09 18:11:12 -0800215 command,
Alex Deymo0d298542016-03-30 18:31:49 -0700216 Subprocess::kRedirectStderrToStdout,
217 {kPostinstallStatusFd},
Alex Deymod15c5462016-03-09 18:11:12 -0800218 base::Bind(&PostinstallRunnerAction::CompletePartitionPostinstall,
219 base::Unretained(this)));
220 // Subprocess::Exec should never return a negative process id.
221 CHECK_GE(current_command_, 0);
222
Alex Deymo0d298542016-03-30 18:31:49 -0700223 if (!current_command_) {
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700224 CompletePartitionPostinstall(1, "Postinstall didn't launch");
Alex Deymo0d298542016-03-30 18:31:49 -0700225 return;
226 }
227
228 // Monitor the status file descriptor.
229 progress_fd_ =
230 Subprocess::Get().GetPipeFd(current_command_, kPostinstallStatusFd);
231 int fd_flags = fcntl(progress_fd_, F_GETFL, 0) | O_NONBLOCK;
232 if (HANDLE_EINTR(fcntl(progress_fd_, F_SETFL, fd_flags)) < 0) {
233 PLOG(ERROR) << "Unable to set non-blocking I/O mode on fd " << progress_fd_;
234 }
235
Hidehiko Abe493fecb2019-07-10 23:30:50 +0900236 progress_controller_ = base::FileDescriptorWatcher::WatchReadable(
Alex Deymo0d298542016-03-30 18:31:49 -0700237 progress_fd_,
Hidehiko Abe493fecb2019-07-10 23:30:50 +0900238 base::BindRepeating(&PostinstallRunnerAction::OnProgressFdReady,
239 base::Unretained(this)));
Darin Petkov6f03a3b2010-11-10 14:27:14 -0800240}
241
Alex Deymo0d298542016-03-30 18:31:49 -0700242void PostinstallRunnerAction::OnProgressFdReady() {
243 char buf[1024];
244 size_t bytes_read;
245 do {
246 bytes_read = 0;
247 bool eof;
248 bool ok =
hscham00b6aa22020-02-20 12:32:06 +0900249 utils::ReadAll(progress_fd_, buf, base::size(buf), &bytes_read, &eof);
Alex Deymo0d298542016-03-30 18:31:49 -0700250 progress_buffer_.append(buf, bytes_read);
251 // Process every line.
252 vector<string> lines = base::SplitString(
253 progress_buffer_, "\n", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL);
254 if (!lines.empty()) {
255 progress_buffer_ = lines.back();
256 lines.pop_back();
257 for (const auto& line : lines) {
258 ProcessProgressLine(line);
259 }
260 }
261 if (!ok || eof) {
262 // There was either an error or an EOF condition, so we are done watching
263 // the file descriptor.
Hidehiko Abe493fecb2019-07-10 23:30:50 +0900264 progress_controller_.reset();
Alex Deymo0d298542016-03-30 18:31:49 -0700265 return;
266 }
267 } while (bytes_read);
268}
269
270bool PostinstallRunnerAction::ProcessProgressLine(const string& line) {
271 double frac = 0;
Alex Deymoa2ea1c22016-08-24 17:26:19 -0700272 if (sscanf(line.c_str(), "global_progress %lf", &frac) == 1 &&
273 !std::isnan(frac)) {
Alex Deymo0d298542016-03-30 18:31:49 -0700274 ReportProgress(frac);
275 return true;
276 }
277
278 return false;
279}
280
281void PostinstallRunnerAction::ReportProgress(double frac) {
282 if (!delegate_)
283 return;
Yoshitaka Ishida128936f2018-02-16 18:20:07 +0900284 if (current_partition_ >= partition_weight_.size() || total_weight_ == 0) {
Alex Deymo0d298542016-03-30 18:31:49 -0700285 delegate_->ProgressUpdate(1.);
286 return;
287 }
Alex Deymo44b35672016-04-05 17:57:48 -0700288 if (!std::isfinite(frac) || frac < 0)
Alex Deymo0d298542016-03-30 18:31:49 -0700289 frac = 0;
290 if (frac > 1)
291 frac = 1;
292 double postinst_action_progress =
293 (accumulated_weight_ + partition_weight_[current_partition_] * frac) /
294 total_weight_;
295 delegate_->ProgressUpdate(postinst_action_progress);
296}
297
298void PostinstallRunnerAction::Cleanup() {
Alex Deymo390efed2016-02-18 11:00:40 -0800299 utils::UnmountFilesystem(fs_mount_dir_);
Alex Deymod15c5462016-03-09 18:11:12 -0800300#ifndef __ANDROID__
Alex Deymo390efed2016-02-18 11:00:40 -0800301 if (!base::DeleteFile(base::FilePath(fs_mount_dir_), false)) {
302 PLOG(WARNING) << "Not removing temporary mountpoint " << fs_mount_dir_;
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700303 }
Alex Deymod15c5462016-03-09 18:11:12 -0800304#endif // !__ANDROID__
Alex Deymo390efed2016-02-18 11:00:40 -0800305 fs_mount_dir_.clear();
Alex Deymo0d298542016-03-30 18:31:49 -0700306
307 progress_fd_ = -1;
Hidehiko Abe493fecb2019-07-10 23:30:50 +0900308 progress_controller_.reset();
Tianjie55abd3c2020-06-19 00:22:59 -0700309
Alex Deymo0d298542016-03-30 18:31:49 -0700310 progress_buffer_.clear();
Alex Deymod15c5462016-03-09 18:11:12 -0800311}
312
313void PostinstallRunnerAction::CompletePartitionPostinstall(
314 int return_code, const string& output) {
315 current_command_ = 0;
Alex Deymo0d298542016-03-30 18:31:49 -0700316 Cleanup();
Alex Deymo31d95ac2015-09-17 11:56:18 -0700317
Darin Petkov6f03a3b2010-11-10 14:27:14 -0800318 if (return_code != 0) {
319 LOG(ERROR) << "Postinst command failed with code: " << return_code;
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700320 ErrorCode error_code = ErrorCode::kPostinstallRunnerError;
Jay Srinivasan1c0fe792013-03-28 16:45:25 -0700321
Andrew de los Reyesfe57d542011-06-07 09:00:36 -0700322 if (return_code == 3) {
Andrew de los Reyesc1d5c932011-04-20 17:15:47 -0700323 // This special return code means that we tried to update firmware,
324 // but couldn't because we booted from FW B, and we need to reboot
325 // to get back to FW A.
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700326 error_code = ErrorCode::kPostinstallBootedFromFirmwareB;
Andrew de los Reyesc1d5c932011-04-20 17:15:47 -0700327 }
Don Garrett81018e02013-07-30 18:46:31 -0700328
329 if (return_code == 4) {
330 // This special return code means that we tried to update firmware,
331 // but couldn't because we booted from FW B, and we need to reboot
332 // to get back to FW A.
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700333 error_code = ErrorCode::kPostinstallFirmwareRONotUpdatable;
Don Garrett81018e02013-07-30 18:46:31 -0700334 }
Alex Deymo5b91c6b2016-08-04 20:33:36 -0700335
336 // If postinstall script for this partition is optional we can ignore the
337 // result.
338 if (install_plan_.partitions[current_partition_].postinstall_optional) {
339 LOG(INFO) << "Ignoring postinstall failure since it is optional";
340 } else {
341 return CompletePostinstall(error_code);
342 }
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700343 }
Alex Deymo0d298542016-03-30 18:31:49 -0700344 accumulated_weight_ += partition_weight_[current_partition_];
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700345 current_partition_++;
Alex Deymo0d298542016-03-30 18:31:49 -0700346 ReportProgress(0);
347
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700348 PerformPartitionPostinstall();
349}
350
351void PostinstallRunnerAction::CompletePostinstall(ErrorCode error_code) {
352 // We only attempt to mark the new slot as active if all the postinstall
353 // steps succeeded.
Sen Jiang02c49422017-10-31 15:14:11 -0700354 if (error_code == ErrorCode::kSuccess) {
355 if (install_plan_.switch_slot_on_reboot) {
Yifan Hong7b3910a2020-03-24 17:47:32 -0700356 if (!boot_control_->GetDynamicPartitionControl()->FinishUpdate(
357 install_plan_.powerwash_required) ||
Yifan Honge8583622019-11-07 11:36:31 -0800358 !boot_control_->SetActiveBootSlot(install_plan_.target_slot)) {
Sen Jiang02c49422017-10-31 15:14:11 -0700359 error_code = ErrorCode::kPostinstallRunnerError;
Tianjie Xud6aa91f2019-11-14 11:55:10 -0800360 } else {
361 // Schedules warm reset on next reboot, ignores the error.
362 hardware_->SetWarmReset(true);
Sen Jiang02c49422017-10-31 15:14:11 -0700363 }
364 } else {
365 error_code = ErrorCode::kUpdatedButNotActive;
366 }
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700367 }
368
369 ScopedActionCompleter completer(processor_, this);
Alex Deymocbc22742016-03-04 17:53:02 -0800370 completer.set_code(error_code);
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700371
Sen Jiang02c49422017-10-31 15:14:11 -0700372 if (error_code != ErrorCode::kSuccess &&
373 error_code != ErrorCode::kUpdatedButNotActive) {
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700374 LOG(ERROR) << "Postinstall action failed.";
375
Alex Deymofb905d92016-06-03 19:26:58 -0700376 // Undo any changes done to trigger Powerwash.
377 if (powerwash_scheduled_)
378 hardware_->CancelPowerwash();
Don Garrett81018e02013-07-30 18:46:31 -0700379
Darin Petkov6f03a3b2010-11-10 14:27:14 -0800380 return;
381 }
Jay Srinivasanae4697c2013-03-18 17:08:08 -0700382
Alex Deymoe5e5fe92015-10-05 09:28:19 -0700383 LOG(INFO) << "All post-install commands succeeded";
Chris Sosad317e402013-06-12 13:47:09 -0700384 if (HasOutputPipe()) {
385 SetOutputObject(install_plan_);
386 }
adlr@google.com3defe6a2009-12-04 20:57:17 +0000387}
388
Alex Deymod15c5462016-03-09 18:11:12 -0800389void PostinstallRunnerAction::SuspendAction() {
390 if (!current_command_)
391 return;
392 if (kill(current_command_, SIGSTOP) != 0) {
393 PLOG(ERROR) << "Couldn't pause child process " << current_command_;
Ben Chan7f4bc3f2017-01-10 15:32:11 -0800394 } else {
395 is_current_command_suspended_ = true;
Alex Deymod15c5462016-03-09 18:11:12 -0800396 }
397}
398
399void PostinstallRunnerAction::ResumeAction() {
400 if (!current_command_)
401 return;
402 if (kill(current_command_, SIGCONT) != 0) {
403 PLOG(ERROR) << "Couldn't resume child process " << current_command_;
Ben Chan7f4bc3f2017-01-10 15:32:11 -0800404 } else {
405 is_current_command_suspended_ = false;
Alex Deymod15c5462016-03-09 18:11:12 -0800406 }
407}
408
409void PostinstallRunnerAction::TerminateProcessing() {
410 if (!current_command_)
411 return;
412 // Calling KillExec() will discard the callback we registered and therefore
413 // the unretained reference to this object.
414 Subprocess::Get().KillExec(current_command_);
Ben Chan7f4bc3f2017-01-10 15:32:11 -0800415
416 // If the command has been suspended, resume it after KillExec() so that the
417 // process can process the SIGTERM sent by KillExec().
418 if (is_current_command_suspended_) {
419 ResumeAction();
420 }
421
Alex Deymod15c5462016-03-09 18:11:12 -0800422 current_command_ = 0;
Alex Deymo0d298542016-03-30 18:31:49 -0700423 Cleanup();
Alex Deymod15c5462016-03-09 18:11:12 -0800424}
425
adlr@google.com3defe6a2009-12-04 20:57:17 +0000426} // namespace chromeos_update_engine