diff --git a/ccache.c b/ccache.c index 7b41f75..2fc0658 100644 --- a/ccache.c +++ b/ccache.c @@ -249,7 +249,7 @@ static void failed(void) cc_log("Failed; falling back to running the real compiler"); if (getenv("CCACHE_VERBOSE")) { - print_executed_command(orig_args->argv); + print_executed_command(stdout, orig_args->argv); } execv(orig_args->argv[0], orig_args->argv); cc_log("execv returned (%s)!", strerror(errno)); diff --git a/ccache.h b/ccache.h index 9aae3ff..0e24290 100644 --- a/ccache.h +++ b/ccache.h @@ -11,6 +11,7 @@ #include #include #include +#include #ifdef __GNUC__ #define ATTR_FORMAT(x, y, z) __attribute__((format (x, y, z))) @@ -134,7 +135,8 @@ int execute(char **argv, const char *path_stdout, const char *path_stderr); char *find_executable(const char *name, const char *exclude_name); -void print_executed_command(char **argv); +void print_command(FILE *fp, char **argv); +void print_executed_command(FILE *fp, char **argv); typedef struct { char **argv; diff --git a/execute.c b/execute.c index cc3845c..d20f2c9 100644 --- a/execute.c +++ b/execute.c @@ -46,7 +46,7 @@ int execute(char **argv, int fd; if (getenv("CCACHE_VERBOSE")) { - print_executed_command(argv); + print_executed_command(stdout, argv); } unlink(path_stdout); @@ -141,12 +141,17 @@ char *find_executable(const char *name, const char *exclude_name) return NULL; } -void print_executed_command(char **argv) +void print_command(FILE *fp, char **argv) { int i; - printf("%s: executing ", MYNAME); for (i = 0; argv[i]; i++) { - printf("%s%s", (i == 0) ? "" : " ", argv[i]); + fprintf(fp, "%s%s", (i == 0) ? "" : " ", argv[i]); } - printf("\n"); + fprintf(fp, "\n"); +} + +void print_executed_command(FILE *fp, char **argv) +{ + fprintf(fp, "%s: executing ", MYNAME); + print_command(fp, argv); }