aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xenpaging/xenpaging.c
diff options
context:
space:
mode:
authorOlaf Hering <olaf@aepfle.de>2011-06-10 10:47:25 +0200
committerOlaf Hering <olaf@aepfle.de>2011-06-10 10:47:25 +0200
commit3ea71e936f7e5a42a2e4c4695d92179fa9ddaff1 (patch)
tree9c49f5023a91f15ce3bf4bf536c8b23557439932 /tools/xenpaging/xenpaging.c
parenta060af0ecc8f7b0abbccce1b0a12abd73e57cf90 (diff)
downloadxen-3ea71e936f7e5a42a2e4c4695d92179fa9ddaff1.tar.gz
xen-3ea71e936f7e5a42a2e4c4695d92179fa9ddaff1.tar.bz2
xen-3ea71e936f7e5a42a2e4c4695d92179fa9ddaff1.zip
xenpaging: add helper function for unlinking pagefile
Unlink pagefile in the signal handler and also in the exit path. This does not leave a stale pagefile if an error occoured. Signed-off-by: Olaf Hering <olaf@aepfle.de> Committed-by: Ian Jackson <ian.jackson.citrix.com>
Diffstat (limited to 'tools/xenpaging/xenpaging.c')
-rw-r--r--tools/xenpaging/xenpaging.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/tools/xenpaging/xenpaging.c b/tools/xenpaging/xenpaging.c
index 2af3a05ec7..72daaad164 100644
--- a/tools/xenpaging/xenpaging.c
+++ b/tools/xenpaging/xenpaging.c
@@ -41,11 +41,20 @@
static char filename[80];
static int interrupted;
-static void close_handler(int sig)
+
+static void unlink_pagefile(void)
{
- interrupted = sig;
if ( filename[0] )
+ {
unlink(filename);
+ filename[0] = '\0';
+ }
+}
+
+static void close_handler(int sig)
+{
+ interrupted = sig;
+ unlink_pagefile();
}
static int xenpaging_mem_paging_flush_ioemu_cache(xenpaging_t *paging)
@@ -716,6 +725,7 @@ int main(int argc, char *argv[])
out:
close(fd);
+ unlink_pagefile();
free(victims);
/* Tear down domain paging */