xbps-bin: re-add libxbps cleanup to the sighandler, also handle SIGHUP.

This commit is contained in:
Juan RP 2012-06-14 10:11:50 +02:00
parent c31d168e2b
commit 29871b2120

View File

@ -38,6 +38,8 @@
#include "defs.h" #include "defs.h"
#include "../xbps-repo/defs.h" #include "../xbps-repo/defs.h"
static struct xbps_handle xh;
static void __attribute__((noreturn)) static void __attribute__((noreturn))
usage(bool fail) usage(bool fail)
{ {
@ -99,13 +101,13 @@ usage(bool fail)
static void __attribute__((noreturn)) static void __attribute__((noreturn))
cleanup(int signum) cleanup(int signum)
{ {
xbps_end(&xh);
exit(signum); exit(signum);
} }
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
struct xbps_handle xh;
struct xferstat xfer; struct xferstat xfer;
struct list_pkgver_cb lpc; struct list_pkgver_cb lpc;
struct sigaction sa; struct sigaction sa;
@ -222,6 +224,7 @@ main(int argc, char **argv)
*/ */
memset(&sa, 0, sizeof(sa)); memset(&sa, 0, sizeof(sa));
sa.sa_handler = cleanup; sa.sa_handler = cleanup;
sigaction(SIGHUP, &sa, NULL);
sigaction(SIGINT, &sa, NULL); sigaction(SIGINT, &sa, NULL);
sigaction(SIGTERM, &sa, NULL); sigaction(SIGTERM, &sa, NULL);