diff options
author | Julian Andres Klode <jak@debian.org> | 2019-05-03 14:51:40 +0000 |
---|---|---|
committer | Julian Andres Klode <jak@debian.org> | 2019-05-03 14:51:40 +0000 |
commit | 9ada8cb08b9d54291993118120712992302b6641 (patch) | |
tree | bcb3a3031af6f0ead0156932453869822567f913 /apt-pkg/deb/dpkgpm.cc | |
parent | e547a738922b434ae0bad32ead26a1a3c2095d1e (diff) | |
parent | 60cc44d160af02c49614653c97bfa3e4e5c9601d (diff) |
Merge branch 'pu/systemd-inhibitor' into 'master'
Prevent shutdown while running dpkg
See merge request apt-team/apt!60
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 101571782..ad5a9007e 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1448,6 +1448,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 = |