diff options
| author | Stefan Boberg <[email protected]> | 2021-06-18 15:42:14 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-06-18 15:42:14 +0200 |
| commit | bd37ad503558c136c2fb9feae91f5ff18ffb83ff (patch) | |
| tree | d9b446f7a601fbd060a3104c49a50740b1bfd6f6 /zenserver/testing/launch.cpp | |
| parent | Fixed FileSystemTraversal::TraverseFileSystem error reporting issue (diff) | |
| download | zen-bd37ad503558c136c2fb9feae91f5ff18ffb83ff.tar.xz zen-bd37ad503558c136c2fb9feae91f5ff18ffb83ff.zip | |
Added process exit code to launcher response
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; } |