Fix signal handler to proper close device, otherwise if the descriptor
is 0, it keeps device open and temporary-cryptsetup-$PID mapping
is not removed (leaving device open and unusable).
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@30
36d66b0a-2a48-0410-832c-
cd162a569da5
/* I miss closures in C! */
static struct setup_backend *cleaner_backend=NULL;
static const char *cleaner_name=NULL;
-static int devfd=0;
+static int devfd=-1;
static void sigint_handler(int sig)
{
- if(devfd)
+ if(devfd >= 0)
close(devfd);
+ devfd = -1;
if(cleaner_backend && cleaner_name)
clear_mapping(cleaner_name, cleaner_backend);
signal(SIGINT, SIG_DFL);
r = 0;
out3:
close(devfd);
- devfd = 0;
+ devfd = -1;
out2:
clear_mapping(name,backend);
out1: