aboutsummaryrefslogtreecommitdiff
path: root/zenserver/testing/launch.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-06-18 15:42:14 +0200
committerStefan Boberg <[email protected]>2021-06-18 15:42:14 +0200
commitbd37ad503558c136c2fb9feae91f5ff18ffb83ff (patch)
treed9b446f7a601fbd060a3104c49a50740b1bfd6f6 /zenserver/testing/launch.cpp
parentFixed FileSystemTraversal::TraverseFileSystem error reporting issue (diff)
downloadzen-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.cpp27
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;
}