Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2015-12-04 14:27:41 -0500
committerAllan McRae <allan@archlinux.org>2015-12-05 18:10:43 +1000
commita8e2578febbb71d1b788c7270c2be57ca1e64dec (patch)
treed696b181d2f333fb2ec0376e4ae5681be0510747 /src
parentb8a72770619a29db436e2a3883ebe03910a8e827 (diff)
remove soft interrupt handler before cleanup
The soft interrupt handler dereferences config, causing a segfault if it is called during cleanup. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'src')
-rw-r--r--src/pacman/pacman.c1
-rw-r--r--src/pacman/sighandler.c10
-rw-r--r--src/pacman/sighandler.h1
3 files changed, 12 insertions, 0 deletions
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index 4237b4d4..2380bd17 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -279,6 +279,7 @@ static void setuseragent(void)
*/
static void cleanup(int ret)
{
+ remove_soft_interrupt_handler();
if(config) {
/* free alpm library resources */
if(config->handle && alpm_release(config->handle) == -1) {
diff --git a/src/pacman/sighandler.c b/src/pacman/sighandler.c
index e88375aa..3f18b5c7 100644
--- a/src/pacman/sighandler.c
+++ b/src/pacman/sighandler.c
@@ -74,6 +74,16 @@ void install_soft_interrupt_handler(void)
sigaction(SIGHUP, &new_action, NULL);
}
+void remove_soft_interrupt_handler(void)
+{
+ struct sigaction new_action;
+ sigemptyset(&new_action.sa_mask);
+ new_action.sa_handler = SIG_DFL;
+ new_action.sa_flags = 0;
+ sigaction(SIGINT, &new_action, NULL);
+ sigaction(SIGHUP, &new_action, NULL);
+}
+
static void segv_handler(int signum)
{
const char msg[] = "\nerror: segmentation fault\n"
diff --git a/src/pacman/sighandler.h b/src/pacman/sighandler.h
index 51f347b6..b9633573 100644
--- a/src/pacman/sighandler.h
+++ b/src/pacman/sighandler.h
@@ -23,6 +23,7 @@
void install_segv_handler(void);
void install_winch_handler(void);
void install_soft_interrupt_handler(void);
+void remove_soft_interrupt_handler(void);
#endif /* _PM_SIGHANDLER_H */