summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2017-04-17 15:54:24 +0300
committerKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2017-04-28 16:19:01 +0300
commitc072c18d6effc5ab0a73bbc1836dedb437555c6f (patch)
treee8786007b095772845f6d216d351fbfbc860cf1d
parent5c349335c76d8b6f1f1e721096d71e3b16f13dbc (diff)
downloadapk-tools-c072c18d6effc5ab0a73bbc1836dedb437555c6f.tar.gz
apk-tools-c072c18d6effc5ab0a73bbc1836dedb437555c6f.tar.bz2
apk-tools-c072c18d6effc5ab0a73bbc1836dedb437555c6f.tar.xz
apk-tools-c072c18d6effc5ab0a73bbc1836dedb437555c6f.zip
close database on SIGINT
cleans up procfs mount
-rw-r--r--src/apk.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/apk.c b/src/apk.c
index 0cf018e..c990102 100644
--- a/src/apk.c
+++ b/src/apk.c
@@ -441,6 +441,14 @@ static void apk_applet_register_builtin(void)
(*p)();
}
+static struct apk_database db;
+
+static void on_sigint(int s)
+{
+ apk_db_close(&db);
+ exit(128 + s);
+}
+
int main(int argc, char **argv)
{
struct apk_applet *applet;
@@ -448,7 +456,6 @@ int main(int argc, char **argv)
struct option *opt, *all_options;
int i, p, r, num_options;
void *ctx = NULL;
- struct apk_database db;
struct apk_db_options dbopts;
const struct apk_option_group **optgroups = default_optgroups;
struct apk_string_array *args;
@@ -517,6 +524,7 @@ int main(int argc, char **argv)
}
apk_db_init(&db);
+ signal(SIGINT, on_sigint);
#ifdef TEST_MODE
dbopts.open_flags &= ~(APK_OPENF_WRITE | APK_OPENF_CACHE_WRITE | APK_OPENF_CREATE);