diff options
author | Julian Andres Klode <julian.klode@canonical.com> | 2019-04-15 11:32:50 +0200 |
---|---|---|
committer | Julian Andres Klode <julian.klode@canonical.com> | 2019-05-07 11:03:28 +0200 |
commit | 8ea79afcadead5a5b7d94bf8623cb833859f6d80 (patch) | |
tree | fca449f0062860556d40f5db1600e0e2193f1408 /apt-pkg/deb/dpkgpm.cc | |
parent | 436d5d5b573a8a30e0868a8af5c624801112377b (diff) |
Prevent shutdown while running dpkg
As long as we are running dpkg, keep an inhibitor that
blocks us from shutting down.
LP: #1820886
(cherry picked from commit 96aef11a5cf400377a52f7e93e70944b17e249d1)
Diffstat (limited to 'apt-pkg/deb/dpkgpm.cc')
-rw-r--r-- | apt-pkg/deb/dpkgpm.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 074e52b3f..a1d329a16 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1463,6 +1463,21 @@ bool pkgDPkgPM::ExpandPendingCalls(std::vector<Item> &List, pkgDepCache &Cache) } bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress) { + struct Inhibitor + { + int Fd = -1; + Inhibitor() + { + if (_config->FindB("DPkg::Inhibit-Shutdown", true)) + Fd = Inhibit("shutdown", "APT", "APT is installing or removing packages", "block"); + } + ~Inhibitor() + { + if (Fd > 0) + close(Fd); + } + } inhibitor; + // explicitly remove&configure everything for hookscripts and progress building // we need them only temporarily through, so keep the length and erase afterwards decltype(List)::const_iterator::difference_type explicitIdx = |