Wait for process to exit before unmounting postinstall partition
When postinstall action is cancelled, update_engine sends SIGKILL to
postinstall scripts and immediately unmounts postinstall partition.
However, if the subprocess hasn't exited yet when we attempt to
unmount, there might be open file descriptors preventing the unmount
Test: th
Bug: 302336751
Change-Id: I2913957eb97a917e328609e801f8c1a944a5673b
diff --git a/common/subprocess_unittest.cc b/common/subprocess_unittest.cc
index ff4158e..8200e68 100644
--- a/common/subprocess_unittest.cc
+++ b/common/subprocess_unittest.cc
@@ -271,16 +271,20 @@
watcher_ = base::FileDescriptorWatcher::WatchReadable(
fifo_fd,
base::Bind(
- [](unique_ptr<base::FileDescriptorWatcher::Controller>* watcher,
+ [](brillo::BaseMessageLoop* loop,
+ unique_ptr<base::FileDescriptorWatcher::Controller>* watcher,
int fifo_fd,
uint32_t tag) {
- char c;
+ char c{};
EXPECT_EQ(1, HANDLE_EINTR(read(fifo_fd, &c, 1)));
EXPECT_EQ('X', c);
LOG(INFO) << "Killing tag " << tag;
Subprocess::Get().KillExec(tag);
+ loop->BreakLoop();
+ ASSERT_TRUE(Subprocess::Get().subprocess_records_.empty());
*watcher = nullptr;
},
+ &loop_,
// watcher_ is no longer used outside the clousure.
base::Unretained(&watcher_),
fifo_fd,