Index: driver/cc1.cc
===================================================================
--- driver/cc1.cc	(revision 6c3744ea42a3b5b7c0caad3216f7a909daf8e9ed)
+++ driver/cc1.cc	(revision 42e2ad789d5cd89e0f2a67a8f6507c685dbdc4ef)
@@ -8,6 +8,6 @@
 // Created On       : Fri Aug 26 14:23:51 2005
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Sat Jan 10 14:16:06 2015
-// Update Count     : 15
+// Last Modified On : Mon Apr 27 23:11:52 2015
+// Update Count     : 39
 //
 
@@ -34,4 +34,7 @@
 string D__CFA_FLAGPREFIX__( "-D__CFA_FLAG__=" );
 
+char tmpname[] = P_tmpdir "/CFAXXXXXX";
+int tmpfilefd = -1;
+
 
 bool prefix( string arg, string pre ) {
@@ -69,4 +72,21 @@
     } // if
 } // checkEnv
+
+
+void rmtmpfile() {
+    if ( unlink( tmpname ) == -1 ) {			// remove tmpname
+	perror ( "CFA Translator error: cpp failed" );
+	exit( EXIT_FAILURE );
+    } // if
+    tmpfilefd = -1;					// mark closed
+} // rmtmpfile
+
+
+void sigTermHandler( int signal ) {
+    if ( tmpfilefd != -1 ) {				// RACE, file created ?
+	rmtmpfile();					// remove
+	exit( EXIT_FAILURE );				// terminate 
+    } // if
+} // sigTermHandler
 
 
@@ -89,4 +109,7 @@
     const char *uargs[20];				// leave space for 20 additional cfa-cpp command line values
     int nuargs = 1;					// 0 => command name
+
+    signal( SIGINT,  sigTermHandler );
+    signal( SIGTERM, sigTermHandler );
 
     // process all the arguments
@@ -116,6 +139,11 @@
 		i += 1;					// and the argument
 
-	    // strip cfa flags controlling cpp step
-
+	    // strip flags controlling cpp step
+
+	    } else if ( arg == "-D__CPP__" ) {
+		cpp_flag = true;
+	    } else if ( arg == "-D" && string( argv[i + 1] ) == "__CPP__" ) {
+		i += 1;					// and the argument
+		cpp_flag = true;
 	    } else if ( arg == "-D__CFA__" ) {
 		CFA_flag = true;
@@ -123,9 +151,4 @@
 		i += 1;					// and the argument
 		CFA_flag = true;
-	    } else if ( arg == "-D__CPP__" ) {
-		cpp_flag = true;
-	    } else if ( arg == "-D" && string( argv[i + 1] ) == "__CPP__" ) {
-		i += 1;					// and the argument
-		cpp_flag = true;
 	    } else if ( prefix( arg, D__CFA_FLAGPREFIX__ ) ) {
 		uargs[nuargs] = ( *new string( arg.substr( D__CFA_FLAGPREFIX__.size() ) ) ).c_str();
@@ -233,7 +256,6 @@
     // Create a temporary file to store output of the C preprocessor.
 
-    char tmpname[] = P_tmpdir "/CFAXXXXXX";
-    int tmpfile = mkstemp( tmpname );
-    if ( tmpfile == -1 ) {
+    tmpfilefd = mkstemp( tmpname );
+    if ( tmpfilefd == -1 ) {
 	perror( "CFA Translator error: cpp level, mkstemp" );
 	exit( EXIT_FAILURE );
@@ -241,5 +263,5 @@
 
 #ifdef __DEBUG_H__
-    cerr << "tmpname:" << tmpname << " tmpfile:" << tmpfile << endl;
+    cerr << "tmpname:" << tmpname << " tmpfilefd:" << tmpfilefd << endl;
 #endif // __DEBUG_H__
 
@@ -280,5 +302,5 @@
 
     if ( WIFSIGNALED(code) != 0 ) {			// child failed ?
-	unlink( tmpname );				// remove tmpname
+	rmtmpfile();					// remove tmpname
 	cerr << "CFA Translator error: cpp failed with signal " << WTERMSIG(code) << endl;
 	exit( EXIT_FAILURE );
@@ -286,5 +308,5 @@
 
     if ( WEXITSTATUS(code) != 0 ) {			// child error ?
-	unlink( tmpname );				// remove tmpname
+	rmtmpfile();					// remove tmpname
 	exit( WEXITSTATUS( code ) );			// do not continue
     } // if
@@ -293,5 +315,5 @@
     // output.  Otherwise, run the cfa-cpp preprocessor on the temporary file and save the result into the output file.
 
-    if ( CFA_flag || fork() == 0 ) {			// conditional fork ?
+    if ( fork() == 0 ) {				// child runs CFA
 	uargs[0] = ( *new string( bprefix + "/cfa-cpp" ) ).c_str();
 
@@ -330,8 +352,5 @@
 
     // Must unlink here because file must exist across execvp.
-    if ( unlink( tmpname ) == -1 ) {
-	perror( "CFA Translator error: cpp level, unlink" );
-	exit( EXIT_FAILURE );
-    } // if
+    rmtmpfile();					// remove tmpname
 
     if ( WIFSIGNALED(code) ) {				// child failed ?
Index: driver/cpp.cc
===================================================================
--- driver/cpp.cc	(revision 6c3744ea42a3b5b7c0caad3216f7a909daf8e9ed)
+++ driver/cpp.cc	(revision 42e2ad789d5cd89e0f2a67a8f6507c685dbdc4ef)
@@ -8,6 +8,6 @@
 // Created On       : Thu Aug 29 12:24:06 2002
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Sat Dec  6 08:31:49 2014
-// Update Count     : 51
+// Last Modified On : Tue Apr 21 07:23:38 2015
+// Update Count     : 52
 // 
 
@@ -218,5 +218,5 @@
     if ( cpp_flag && CFA_flag ) {
 	cerr << argv[0] << " Error cannot use -E and -CFA flags together." << endl;
-	exit( -1 );
+	exit( EXIT_FAILURE );
     } // if
 
@@ -234,5 +234,5 @@
 	    if ( freopen( cpp_out.c_str(), "w", stdout ) == NULL ) { // redirect stdout if not -E
 		cerr << argv[0] << ": Error can't write to " << cpp_out << endl;
-		exit( -1 );
+		exit( EXIT_FAILURE );
 	    } // if
 
@@ -274,5 +274,5 @@
 	execvp( args[0], (char *const *)args );		// should not return
 	perror( "CFA translator error: cpp level, exec" );
-	exit( -1 );
+	exit( EXIT_FAILURE );
     } // if
 
@@ -282,5 +282,5 @@
 	if ( freopen( tmpfile, "w", stdout ) == NULL) {	// redirect output to tmpfile
 	    cerr << argv[0] << ": Error can't write to " << tmpfile << endl;
-	    exit( -1 );
+	    exit( EXIT_FAILURE );
 	} // if
 
@@ -308,5 +308,5 @@
 	execvp( args[0], (char *const *)args );		// should not return
 	perror( "CFA translator error: cpp level, exec" );
-	exit( -1 );
+	exit( EXIT_FAILURE );
     } // if
 
@@ -316,5 +316,5 @@
 	unlink( tmpfile );
 	cerr << "CFA translator error: cpp failed with signal " << WTERMSIG(code) << endl;
-	exit( -1 );
+	exit( EXIT_FAILURE );
     } // if
 
@@ -357,13 +357,16 @@
     wait( &code );					// wait for child to finish
 
-    unlink( tmpfile );
+    if ( unlink( tmpfile ) == -1 ) {
+	cerr << "CFA translator error: cfa-cpp failed " << errno << " to remove temporary file \"" << tmpfile << "\"" << endl;
+	exit( EXIT_FAILURE );
+    } // if
 
     if ( WIFSIGNALED(code) != 0 ) {			// child completed successfully ?
 	cerr << "CFA translator error: cfa-cpp failed with signal " << WTERMSIG(code) << endl;
-	exit( -1 );
+	exit( EXIT_FAILURE );
     } // if
 
     if ( CFA_flag ) {					// -CFA flag ?
-	exit( -1 );					// tell gcc not to go any further
+	exit( EXIT_FAILURE );				// tell gcc not to go any further
     } else {
 	exit( WEXITSTATUS(code) );
