Alexandre Julliard : wmc: Clean output files when aborting on an error or signal.

Alexandre Julliard julliard at wine.codeweavers.com
Sat May 27 06:34:40 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: 22aad63775337f61ebed66e4f7c2696287c749fa
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=22aad63775337f61ebed66e4f7c2696287c749fa

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Sat May 27 13:23:24 2006 +0200

wmc: Clean output files when aborting on an error or signal.

---

 tools/wmc/wmc.c |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/tools/wmc/wmc.c b/tools/wmc/wmc.c
index f852f2b..9a19654 100644
--- a/tools/wmc/wmc.c
+++ b/tools/wmc/wmc.c
@@ -116,6 +116,17 @@ time_t now;			/* The time of start of wm
 int getopt (int argc, char *const *argv, const char *optstring);
 static void segvhandler(int sig);
 
+static void cleanup_files(void)
+{
+    if (output_name) unlink( output_name );
+    if (header_name) unlink( header_name );
+}
+
+static void exit_on_signal( int sig )
+{
+    exit(1);  /* this will call the atexit functions */
+}
+
 int main(int argc,char *argv[])
 {
 	extern char* optarg;
@@ -126,7 +137,13 @@ int main(int argc,char *argv[])
 	int i;
 	int cmdlen;
 
+	atexit( cleanup_files );
 	signal(SIGSEGV, segvhandler);
+	signal( SIGTERM, exit_on_signal );
+	signal( SIGINT, exit_on_signal );
+#ifdef SIGHUP
+	signal( SIGHUP, exit_on_signal );
+#endif
 
 	now = time(NULL);
 
@@ -269,7 +286,8 @@ int main(int argc,char *argv[])
 	write_rc_file(output_name);
 	if(!rcinline)
 		write_bin_files();
-
+	output_name = NULL;
+	header_name = NULL;
 	return 0;
 }
 




More information about the wine-cvs mailing list