- Support external zlib in nonstandard directory.
+- Avoid calling `exit()` inside an exit handler.
+
ccache 3.2.2
------------
close(fd);
tmp_unlink(tmp_stderr);
- exit(status);
+ x_exit(status);
}
tmp_unlink(tmp_stderr);
}
/* and exit with the right status code */
- exit(0);
+ x_exit(0);
}
/* find the real compiler. We just search the PATH to find a executable of the
/* run real compiler, sending output to cache */
to_cache(compiler_args);
- exit(0);
+ x_exit(0);
}
static void
case 'h': /* --help */
fputs(USAGE_TEXT, stdout);
- exit(0);
+ x_exit(0);
case 'F': /* --max-files */
{
case 'V': /* --version */
fprintf(stdout, VERSION_TEXT, CCACHE_VERSION);
- exit(0);
+ x_exit(0);
case 'z': /* --zero-stats */
initialize();
default:
fputs(USAGE_TEXT, stderr);
- exit(1);
+ x_exit(1);
}
}
if (same_executable_name(program_name, MYNAME)) {
if (argc < 2) {
fputs(USAGE_TEXT, stderr);
- exit(1);
+ x_exit(1);
}
/* if the first argument isn't an option, then assume we are
being passed a compiler name and options */
bool is_absolute_path(const char *path);
bool is_full_path(const char *path);
void update_mtime(const char *path);
+void x_exit(int status) ATTR_NORETURN;
int x_rename(const char *oldpath, const char *newpath);
int tmp_unlink(const char *path);
int x_unlink(const char *path);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
if (!doreturn)
- exit(exitcode);
+ x_exit(exitcode);
return exitcode;
}
close(fd_out);
dup2(fd_err, 2);
close(fd_err);
- exit(execv(argv[0], argv));
+ x_exit(execv(argv[0], argv));
}
close(fd_out);
/*
- * Copyright (C) 2010, 2012 Joel Rosdahl
+ * Copyright (C) 2010-2015 Joel Rosdahl
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
exitfn_call(void)
{
struct exit_function *p = exit_functions, *q;
+ exit_functions = NULL;
while (p) {
p->function(p->context);
q = p;
p = p->next;
free(q);
}
- exit_functions = NULL;
}
/* Note: Can't call fatal() since that would lead to recursion. */
fprintf(stderr, "ccache: error: Failed to write to %s: %s\n",
conf->log_file, strerror(errno));
- exit(EXIT_FAILURE);
+ x_exit(EXIT_FAILURE);
}
static void
fputs(prefix, logfile);
print_command(logfile, argv);
rc = fflush(logfile);
- if (rc)
+ if (rc) {
warn_log_fail();
+ }
}
/* something went badly wrong! */
cc_log("FATAL: %s", msg);
fprintf(stderr, "ccache: error: %s\n", msg);
- exit(1);
+ x_exit(1);
}
/*
}
/*
- * Rename oldpath to newpath (deleting newpath).
+ * If exit() already has been called, call _exit(), otherwise exit(). This is
+ * used to avoid calling exit() inside an atexit handler.
*/
+void
+x_exit(int status)
+{
+ static bool first_time = true;
+ if (first_time) {
+ first_time = false;
+ exit(status);
+ } else {
+ _exit(status);
+ }
+}
+/*
+ * Rename oldpath to newpath (deleting newpath).
+ */
int
x_rename(const char *oldpath, const char *newpath)
{