cmd_execute_and_stream_data: Determine right exit codes
MODIFY
src/vcpkg/base/system.process.cpp
src/vcpkg/base/system.process.cpp
#include <ctime>
#include <future>
+#include <sstream>
#if defined(__APPLE__)
#include <mach-o/dyld.h>
@@ -773,7 +774,11 @@ namespace vcpkg
const Environment& env)
{
const auto timer = ElapsedTimer::create_started();
-
+ const auto thread_id = []() {
+ std::ostringstream ss;
+ ss << std::this_thread::get_id();
+ return ss.str();
+ }();
#if defined(_WIN32)
using vcpkg::g_ctrl_c_state;
@@ -803,7 +808,7 @@ namespace vcpkg
.extract();
}
- Debug::print("popen(", actual_cmd_line, ")\n");
+ Debug::print(thread_id, ": popen(", actual_cmd_line, ")\n");
// Flush stdout before launching external process
fflush(stdout);
@@ -824,11 +829,24 @@ namespace vcpkg
return 1;
}
- const auto exit_code = pclose(pipe);
+ auto exit_code = pclose(pipe);
+ if (WIFEXITED(exit_code))
+ {
+ exit_code = WEXITSTATUS(exit_code);
+ }
+ else if (WIFSIGNALED(exit_code))
+ {
+ exit_code = WTERMSIG(exit_code);
+ }
+ else if (WIFSTOPPED(exit_code))
+ {
+ exit_code = WSTOPSIG(exit_code);
+ }
#endif
const auto elapsed = timer.us_64();
g_subprocess_stats += elapsed;
- Debug::print("cmd_execute_and_stream_data() returned ",
+ Debug::print(thread_id,
+ ": cmd_execute_and_stream_data() returned ",
exit_code,
" after ",
Strings::format("%8llu", static_cast<unsigned long long>(elapsed)),

cmd_execute_and_stream_data: Determine right exit codes (#305)