{
char *e;
- /* delete intermediate pre-processor file if needed */
- if (i_tmpfile) {
- if (!direct_i_file) {
- unlink(i_tmpfile);
- }
- free(i_tmpfile);
- i_tmpfile = NULL;
- }
-
- /* delete the cpp stderr file if necessary */
- if (cpp_stderr) {
- unlink(cpp_stderr);
- free(cpp_stderr);
- cpp_stderr = NULL;
- }
-
/* strip any local args */
args_strip(orig_args, "--ccache-");
fatal("%s: execv returned (%s)", orig_args->argv[0], strerror(errno));
}
+static void
+clean_up_tmp_files()
+{
+ /* delete intermediate pre-processor file if needed */
+ if (i_tmpfile) {
+ if (!direct_i_file) {
+ unlink(i_tmpfile);
+ }
+ free(i_tmpfile);
+ i_tmpfile = NULL;
+ }
+
+ /* delete the cpp stderr file if necessary */
+ if (cpp_stderr) {
+ unlink(cpp_stderr);
+ free(cpp_stderr);
+ cpp_stderr = NULL;
+ }
+}
+
/*
* Transform a name to a full path into the cache directory, creating needed
* sublevels if needed. Caller frees.
close(fd_real_stderr);
close(fd_result);
unlink(tmp_stderr2);
- unlink(cpp_stderr);
free(tmp_stderr2);
- free(cpp_stderr);
- cpp_stderr = NULL;
}
if (status != 0) {
copy_fd(fd, 2);
close(fd);
unlink(tmp_stderr);
- if (i_tmpfile && !direct_i_file) {
- unlink(i_tmpfile);
- }
exit(status);
}
}
}
}
- /* get rid of the intermediate preprocessor file */
- if (i_tmpfile) {
- if (!direct_i_file) {
- unlink(i_tmpfile);
- }
- free(i_tmpfile);
- i_tmpfile = NULL;
- }
-
- /* Delete the cpp stderr file if necessary. */
- if (cpp_stderr) {
- unlink(cpp_stderr);
- free(cpp_stderr);
- cpp_stderr = NULL;
- }
-
/* Send the stderr, if any. */
fd_stderr = open(cached_stderr, O_RDONLY | O_BINARY);
if (fd_stderr != -1) {
exitfn_init();
exitfn_add_nullary(stats_flush);
+ exitfn_add_nullary(clean_up_tmp_files);
/* check for logging early so cc_log messages start working ASAP */
cache_logfile = getenv("CCACHE_LOGFILE");