diff options
Diffstat (limited to 'zenserver/testing/launch.cpp')
| -rw-r--r-- | zenserver/testing/launch.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/zenserver/testing/launch.cpp b/zenserver/testing/launch.cpp index 119055e44..2f8f40035 100644 --- a/zenserver/testing/launch.cpp +++ b/zenserver/testing/launch.cpp @@ -35,6 +35,7 @@ public: void SetWorkingDirectory(const std::filesystem::path& WorkingDirectory) { m_WorkingDirectory = WorkingDirectory; } bool SpawnJob(std::filesystem::path ExePath, std::wstring CommandLine); bool Wait(uint32_t TimeoutMs = ~0); + int ExitCode(); private: std::filesystem::path m_WorkingDirectory; @@ -106,6 +107,26 @@ BasicJob::Wait(uint32_t TimeoutMs) throw std::exception("Failed wait on process handle"); } +int +BasicJob::ExitCode() +{ + DWORD Ec =0; + BOOL Success = GetExitCodeProcess(m_ProcessHandle, &Ec); + + if (!Success) + { + spdlog::warn("failed getting exit code"); + } + + if (Ec == STILL_ACTIVE) + { + spdlog::warn("getting exit code but process is STILL_ACTIVE"); + } + + return gsl::narrow_cast<int>(Ec); +} + + struct SandboxedJob { SandboxedJob() = default; @@ -460,7 +481,11 @@ HttpLaunchService::HttpLaunchService(CasStore& Store) Job.SpawnJob(ExeName, Args); Job.Wait(); - return HttpReq.WriteResponse(HttpResponse::OK); + CbObjectWriter Response; + + Response << "exitcode" << Job.ExitCode(); + + return HttpReq.WriteResponse(HttpResponse::OK, Response.Save()); } break; } |