index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Chantry Xavier <shiningxc@gmail.com> | 2008-03-09 12:56:00 +0100 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2008-03-09 11:30:59 -0500 |
commit | 2f9f48edddadffa2ac39ed7291f92be7be3b0fb5 (patch) | |
tree | e8853dae93f3253ebd7301283a4594de2952035a /src | |
parent | 1dfcf1495ba4c0ac36d770ef892483459e5678c4 (diff) |
-rw-r--r-- | src/pacman/pacman.c | 43 |
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index d6997689..f46b71c1 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -188,11 +188,31 @@ static void setuseragent(void) setenv("HTTP_USER_AGENT", agent, 0); } +/** Free the resources. + * + * @param ret the return value + */ +static void cleanup(int ret) { + /* free alpm library resources */ + if(alpm_release() == -1) { + pm_printf(PM_LOG_ERROR, alpm_strerrorlast()); + } + + /* free memory */ + FREELIST(pm_targets); + if(config) { + config_free(config); + config = NULL; + } + + exit(ret); +} + /** Catches thrown signals. Performs necessary cleanup to ensure database is * in a consistant state. * @param signum the thrown signal */ -static void cleanup(int signum) +static void handler(int signum) { if(signum==SIGSEGV) { @@ -211,20 +231,7 @@ static void cleanup(int signum) /* output a newline to be sure we clear any line we may be on */ printf("\n"); } - - /* free alpm library resources */ - if(alpm_release() == -1) { - pm_printf(PM_LOG_ERROR, alpm_strerrorlast()); - } - - /* free memory */ - FREELIST(pm_targets); - if(config) { - config_free(config); - config = NULL; - } - - exit(signum); + cleanup(signum); } /** Sets all libalpm required paths in one go. Called after the command line @@ -756,9 +763,9 @@ int main(int argc, char *argv[]) #endif /* set signal handlers */ - signal(SIGINT, cleanup); - signal(SIGTERM, cleanup); - signal(SIGSEGV, cleanup); + signal(SIGINT, handler); + signal(SIGTERM, handler); + signal(SIGSEGV, handler); /* i18n init */ #if defined(ENABLE_NLS) |