summaryrefslogtreecommitdiff
path: root/apt-pkg/deb
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2016-08-19 13:00:33 +0200
committerJulian Andres Klode <jak@debian.org>2016-08-19 16:45:03 +0200
commita6ae3d3df490e7a5a1c8324ba9dc2e63972b1529 (patch)
tree992d323202c695382eb098fdf6551a461109f4a3 /apt-pkg/deb
parent0eaa491c63d0583812a795f872be71ea54e7f01d (diff)
Ignore SIGINT and SIGQUIT for Pre-Install hooks
Instead of erroring out when receiving a SIGINT, let the child deal with it - we'll error out anyway if the child exits with an error or due to the signal. Also ignore SIGQUIT, as system() ignores it. This basically fixes Bug #832593, but: we are running the hooks via sh -c. Some shells exit with a signal error even if the command they are executing catches the signal and exits successfully. So far, this has been noticed on dash, which unfortunately, is our default shell. Example: $ cat trap.sh trap 'echo int' INT; sleep 10; exit 0 $ if dash -c ./trap.sh; then echo OK: $?; else echo FAIL: $?; fi ^Cint FAIL: 130 $ if mksh -c ./trap.sh; then echo OK: $?; else echo FAIL: $?; fi ^Cint OK: 0 $ if bash -c ./trap.sh; then echo OK: $?; else echo FAIL: $?; fi ^Cint OK: 0
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r--apt-pkg/deb/dpkgpm.cc10
1 files changed, 3 insertions, 7 deletions
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 54a8dffd7..5759e6ba5 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -417,7 +417,6 @@ 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)
@@ -425,9 +424,8 @@ 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;
- });
+ sighandler_t old_sigint = signal(SIGINT, SIG_IGN);
+ sighandler_t old_sigquit = signal(SIGQUIT, SIG_IGN);
unsigned int Count = 1;
for (; Opts != 0; Opts = Opts->Next, Count++)
@@ -528,9 +526,7 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf)
}
signal(SIGINT, old_sigint);
signal(SIGPIPE, old_sigpipe);
-
- if (interrupted)
- result = _error->Error("Interrupted");
+ signal(SIGQUIT, old_sigquit);
return result;
}