diff --git a/src/build.cc b/src/build.cc index 17cf950124..651a824538 100644 --- a/src/build.cc +++ b/src/build.cc @@ -796,11 +796,7 @@ void Builder::Cleanup() { } } - if (compiler_log_) { - fprintf(compiler_log_, "#Done(%" PRId64 ")\n", GetTimeMillis()); - fclose(compiler_log_); - compiler_log_ = NULL; - } + compiler_log_ = NULL; } Node* Builder::AddTarget(const string& name, string* err) { diff --git a/src/ninja.cc b/src/ninja.cc index 590c416ec8..3114fc595a 100644 --- a/src/ninja.cc +++ b/src/ninja.cc @@ -1172,19 +1172,27 @@ int NinjaMain::RunBuild(int argc, char** argv) { printf("ninja: build stopped: %s.\n", err.c_str()); #else - if(ShouldBeColorFul(false)){ - printf("\x1b[31m" "FAILED:" "\x1b[0m" " %s.\n", err.c_str()); - } else { - printf("FAILED: %s.\n", err.c_str()); - } + if (ShouldBeColorFul(false)) { + printf("\x1b[31m" "FAILED:" "\x1b[0m" " %s.\n", err.c_str()); + } else { + printf("FAILED: %s.\n", err.c_str()); + } + fprintf(compiler_log_, "FAILED: %s.\n", err.c_str()); #endif + + fprintf(compiler_log_, "#Done(%" PRId64 ")\n", GetTimeMillis()); + fclose(compiler_log_); + if (err.find("interrupted by user") != string::npos) { return 2; } return 1; } + fprintf(compiler_log_, "#Done(%" PRId64 ")\n", GetTimeMillis()); + fclose(compiler_log_); + return 0; }