Files
zaloopipe/pipeline-runner/src/processexecutor.cpp
T
andrey 5ca6927baa feat: add ProcessExecutor, FAKE mode, fix thread lifecycle crash
- Add ProcessExecutor class wrapping PIProcess with proper cleanup
- Add CMake FAKE option (-DFAKE=ON) for testing without opencode
- Add 3 FAKE-mode tests for full pipeline execution, status transitions, output
- Fix PIThread lifecycle: use startOnce() instead of start(), track threads,
  wait + delete in destructor to prevent use-after-free of PIDeque<PIChar>
- Update build.sh with --fake flag and automatic cache invalidation
- Upgrade CMake to C++17 standard
- Update AGENTS.md with build commands and FAKE mode
2026-07-16 09:51:39 +03:00

31 lines
809 B
C++

#include "processexecutor.h"
#include <pibytearray.h>
#include <piprocess.h>
#include <pisystemtime.h>
ProcessResult ProcessExecutor::run(const PIString & command, const PIStringList & args, int timeoutSeconds, const PIString & workingDir) {
PIProcess proc;
proc.enableReadStdOut(true);
proc.enableReadStdErr(true);
if (!workingDir.isEmpty()) {
proc.setWorkingDirectory(workingDir);
}
proc.exec(command, args);
proc.waitForFinish(PISystemTime::fromSeconds(timeoutSeconds));
PIByteArray stdoutData = proc.readOutput();
PIByteArray stderrData = proc.readError();
int rc = proc.exitCode();
proc.stopAndWait();
ProcessResult result;
result.exitCode = rc;
result.output = PIString::fromUTF8(stdoutData);
result.error = PIString::fromUTF8(stderrData);
return result;
}