aboutsummaryrefslogtreecommitdiff
path: root/src/zencore/process.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zencore/process.cpp')
-rw-r--r--src/zencore/process.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/zencore/process.cpp b/src/zencore/process.cpp
index 226a94050..f657869dc 100644
--- a/src/zencore/process.cpp
+++ b/src/zencore/process.cpp
@@ -9,6 +9,7 @@
#include <zencore/string.h>
#include <zencore/testing.h>
#include <zencore/timer.h>
+#include <zencore/trace.h>
#include <thread>
@@ -745,6 +746,8 @@ CreateProcElevated(const std::filesystem::path& Executable, std::string_view Com
CreateProcResult
CreateProc(const std::filesystem::path& Executable, std::string_view CommandLine, const CreateProcOptions& Options)
{
+ ZEN_TRACE_CPU("CreateProc");
+
#if ZEN_PLATFORM_WINDOWS
if (Options.Flags & CreateProcOptions::Flag_Unelevated)
{
@@ -776,6 +779,17 @@ CreateProc(const std::filesystem::path& Executable, std::string_view CommandLine
ZEN_UNUSED(Result);
}
+ if (!Options.StdoutFile.empty())
+ {
+ int Fd = open(Options.StdoutFile.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0644);
+ if (Fd >= 0)
+ {
+ dup2(Fd, STDOUT_FILENO);
+ dup2(Fd, STDERR_FILENO);
+ close(Fd);
+ }
+ }
+
if (execv(Executable.c_str(), ArgV.data()) < 0)
{
ThrowLastError("Failed to exec() a new process image");