#include <linux/fs.h>
#include <errno.h>
#include <assert.h>
+#include <signal.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <libdevmapper.h>
static int _verbose = 1;
static int _fips_mode = 0;
+static int _quit = 0;
+
static char global_log[4096];
static int global_lines = 0;
else
printf(" [%s,%s:%d] %s\n", msg, func, line, tst);
}
+ if (_quit) {
+ if (_verbose)
+ printf("Interrupted by a signal.\n");
+ _cleanup();
+ exit(-1);
+ }
}
/* crypt_device context must be "cd" to parse error properly here */
crypt_free(cd);
}
+static void int_handler(int sig __attribute__((__unused__)))
+{
+ _quit++;
+}
+
int main(int argc, char *argv[])
{
+ struct sigaction sa = { .sa_handler = int_handler };
int i;
if (getuid() != 0) {
_debug = _verbose = 1;
}
+ /* Handle interrupt properly */
+ sigaction(SIGINT, &sa, NULL);
+ sigaction(SIGTERM, &sa, NULL);
+
_cleanup();
if (_setup())
goto out;