diff --git a/src/build.h b/src/build.h index ba39e7728a..1479ab9407 100644 --- a/src/build.h +++ b/src/build.h @@ -155,7 +155,7 @@ struct CommandRunner { struct Result { Result() : edge(NULL) {} Edge* edge; - ExitStatus status; + int status; std::string output; bool success() const { return status == ExitSuccess; } }; diff --git a/src/subprocess-posix.cc b/src/subprocess-posix.cc index 8e785406c9..af224f734d 100644 --- a/src/subprocess-posix.cc +++ b/src/subprocess-posix.cc @@ -147,7 +147,7 @@ void Subprocess::OnPipeReady() { } } -ExitStatus Subprocess::Finish() { +int Subprocess::Finish() { assert(pid_ != -1); int status; if (waitpid(pid_, &status, 0) < 0) @@ -164,8 +164,9 @@ ExitStatus Subprocess::Finish() { } #endif + int exit = 0; if (WIFEXITED(status)) { - int exit = WEXITSTATUS(status); + exit = WEXITSTATUS(status); if (exit == 0) return ExitSuccess; } else if (WIFSIGNALED(status)) { @@ -173,7 +174,7 @@ ExitStatus Subprocess::Finish() { || WTERMSIG(status) == SIGHUP) return ExitInterrupted; } - return ExitFailure; + return exit; } bool Subprocess::Done() const { diff --git a/src/subprocess-win32.cc b/src/subprocess-win32.cc index ff3baaca7f..87d529d070 100644 --- a/src/subprocess-win32.cc +++ b/src/subprocess-win32.cc @@ -185,22 +185,21 @@ void Subprocess::OnPipeReady() { // function again later and get them at that point. } -ExitStatus Subprocess::Finish() { +int Subprocess::Finish() { if (!child_) return ExitFailure; // TODO: add error handling for all of these. WaitForSingleObject(child_, INFINITE); - DWORD exit_code = 0; + int exit_code = 0; GetExitCodeProcess(child_, &exit_code); CloseHandle(child_); child_ = NULL; - return exit_code == 0 ? ExitSuccess : - exit_code == CONTROL_C_EXIT ? ExitInterrupted : - ExitFailure; + return exit_code == CONTROL_C_EXIT ? ExitInterrupted : + exit_code; } bool Subprocess::Done() const { diff --git a/src/subprocess.h b/src/subprocess.h index 9e3d2ee98f..a9a3fd9a15 100644 --- a/src/subprocess.h +++ b/src/subprocess.h @@ -44,7 +44,7 @@ struct Subprocess { /// Returns ExitSuccess on successful process exit, ExitInterrupted if /// the process was interrupted, ExitFailure if it otherwise failed. - ExitStatus Finish(); + int Finish(); bool Done() const; diff --git a/src/subprocess_test.cc b/src/subprocess_test.cc index 073fe86931..8088d16d8e 100644 --- a/src/subprocess_test.cc +++ b/src/subprocess_test.cc @@ -14,6 +14,7 @@ #include "subprocess.h" +#include "exit_status.h" #include "test.h" #ifndef _WIN32 @@ -50,7 +51,10 @@ TEST_F(SubprocessTest, BadCommandStderr) { subprocs_.DoWork(); } - EXPECT_EQ(ExitFailure, subproc->Finish()); + int exit = subproc->Finish(); + EXPECT_NE(ExitSuccess, exit); + EXPECT_NE(ExitFailure, exit); + EXPECT_NE(ExitInterrupted, exit); EXPECT_NE("", subproc->GetOutput()); } @@ -64,7 +68,10 @@ TEST_F(SubprocessTest, NoSuchCommand) { subprocs_.DoWork(); } - EXPECT_EQ(ExitFailure, subproc->Finish()); + int exit = subproc->Finish(); + EXPECT_NE(ExitSuccess, exit); + EXPECT_NE(ExitFailure, exit); + EXPECT_NE(ExitInterrupted, exit); EXPECT_NE("", subproc->GetOutput()); #ifdef _WIN32 ASSERT_EQ("CreateProcess failed: The system cannot find the file "