Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 886222d

Browse files
committed
fix: windows
1 parent f7cb0ae commit 886222d

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

engine/extensions/local-engine/local_engine.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,9 @@ void LocalEngine::LoadModel(std::shared_ptr<Json::Value> json_body,
548548
auto log_path =
549549
(file_manager_utils::GetCortexLogPath() / "logs" / "cortex.log").string();
550550
CTL_DBG("log: " << log_path);
551-
auto result = cortex::process::SpawnProcess(v, log_path, log_path);
551+
auto result = cortex::process::SpawnProcess(
552+
v, log_path, log_path,
553+
file_manager_utils::GetExecutableFolderContainerPath().string());
552554
if (result.has_error()) {
553555
CTL_ERR("Fail to spawn process. " << result.error());
554556
Json::Value error;

engine/utils/process/utils.cc

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ std::vector<char*> ConvertToArgv(const std::vector<std::string>& args) {
4242

4343
cpp::result<ProcessInfo, std::string> SpawnProcess(
4444
const std::vector<std::string>& command, const std::string& stdout_file,
45-
const std::string& stderr_file) {
45+
const std::string& stderr_file, const std::string& current_directory) {
4646
std::stringstream ss;
4747
for (const auto item : command) {
4848
ss << item << " ";
@@ -109,17 +109,21 @@ cpp::result<ProcessInfo, std::string> SpawnProcess(
109109

110110
// create a suspended process. we will resume it later after adding it to
111111
// a job (see below)
112-
if (!CreateProcessA(NULL, // lpApplicationName
113-
command_buffer, // lpCommandLine
114-
NULL, // lpProcessAttributes
115-
NULL, // lpThreadAttributes
116-
TRUE, // bInheritHandles
117-
CREATE_SUSPENDED, // dwCreationFlags
118-
NULL, // lpEnvironment
119-
NULL, // lpCurrentDirectory
120-
&si, // lpStartupInfo
121-
&pi // lpProcessInformation
122-
)) {
112+
if (!CreateProcessA(
113+
NULL, // lpApplicationName
114+
command_buffer, // lpCommandLine
115+
NULL, // lpProcessAttributes
116+
NULL, // lpThreadAttributes
117+
TRUE, // bInheritHandles
118+
CREATE_SUSPENDED, // dwCreationFlags
119+
NULL, // lpEnvironment
120+
current_directory.empty()
121+
? NULL
122+
: const_cast<char*>(
123+
current_directory.c_str()), // lpCurrentDirectory
124+
&si, // lpStartupInfo
125+
&pi // lpProcessInformation
126+
)) {
123127
if (hStdOut != NULL)
124128
CloseHandle(hStdOut);
125129
if (hStdErr != NULL)

engine/utils/process/utils.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ std::vector<char*> ConvertToArgv(const std::vector<std::string>& args);
3636

3737
cpp::result<ProcessInfo, std::string> SpawnProcess(
3838
const std::vector<std::string>& command,
39-
const std::string& stdout_file = "", const std::string& stderr_file = "");
39+
const std::string& stdout_file = "", const std::string& stderr_file = "",
40+
const std::string& current_directory = "");
4041
bool IsProcessAlive(ProcessInfo& proc_info);
4142
bool WaitProcess(ProcessInfo& proc_info);
4243
bool KillProcess(ProcessInfo& proc_info);

0 commit comments

Comments
 (0)