From mboxrd@z Thu Jan 1 00:00:00 1970 From: Olaf Hering Subject: [PATCH 19 of 22] xenpaging: add helper function for unlinking pagefile Date: Fri, 10 Jun 2011 11:13:08 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org # HG changeset patch # User Olaf Hering # Date 1307695645 -7200 # Node ID c375ced18c763dd7dcebfdc923f1d5154656b578 # Parent 3d8e65d22c13aeebe3f1e25e2dd9724c3efcf8d6 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 diff -r 3d8e65d22c13 -r c375ced18c76 tools/xenpaging/xenpaging.c --- a/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:24 2011 +0200 +++ b/tools/xenpaging/xenpaging.c Fri Jun 10 10:47:25 2011 +0200 @@ -41,11 +41,20 @@ static char filename[80]; static int interrupted; + +static void unlink_pagefile(void) +{ + if ( filename[0] ) + { + unlink(filename); + filename[0] = '\0'; + } +} + static void close_handler(int sig) { interrupted = sig; - if ( filename[0] ) - unlink(filename); + 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 */