summaryrefslogtreecommitdiff
path: root/apt-pkg/deb/dpkgpm.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2016-08-07 00:45:25 +0200
committerJulian Andres Klode <jak@debian.org>2016-08-07 00:45:25 +0200
commitb2cfacf1180e4b3fcbb2ae2ea52cf270ef74e971 (patch)
treece900add2de24419cadf12a7ccc764e414626246 /apt-pkg/deb/dpkgpm.cc
parent4adc750a2a8d0c6b2c03353b5538bc7446020f68 (diff)
Handle interrupt when running Pre-Install hooks
If we receive an interrupt, set a flag and do not abort immediately without waiting for the child. Once the child exited, exit with an error if the interrupted flag is set. Closes: #832593
Diffstat (limited to 'apt-pkg/deb/dpkgpm.cc')
-rw-r--r--apt-pkg/deb/dpkgpm.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index c1b9a28f4..6aa1ce426 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -403,6 +403,7 @@ bool pkgDPkgPM::SendPkgsInfo(FILE * const F, unsigned int const &Version)
bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf)
{
bool result = true;
+ static bool interrupted = false;
Configuration::Item const *Opts = _config->Tree(Cnf);
if (Opts == 0 || Opts->Child == 0)
@@ -410,6 +411,9 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf)
Opts = Opts->Child;
sighandler_t old_sigpipe = signal(SIGPIPE, SIG_IGN);
+ sighandler_t old_sigint = signal(SIGINT, [](int signum){
+ interrupted = true;
+ });
unsigned int Count = 1;
for (; Opts != 0; Opts = Opts->Next, Count++)
@@ -508,8 +512,12 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf)
break;
}
}
+ signal(SIGINT, old_sigint);
signal(SIGPIPE, old_sigpipe);
+ if (interrupted)
+ result = _error->Error("Interrupted");
+
return result;
}
/*}}}*/