1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-08-13 17:03:46 -04:00

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>
This commit is contained in:
Andrew Gregory 2015-12-04 14:27:41 -05:00 committed by Allan McRae
parent b8a7277061
commit a8e2578feb
3 changed files with 12 additions and 0 deletions

View File

@ -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) {

View File

@ -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"

View File

@ -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 */