From da6be80f18014a3972eedf05099cd0066e9eae04 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 3 Dec 2021 11:45:01 -0500 Subject: Split out ExecutableLocation (#2041) * #include an absolute path didn't work - because paths were taken to always be relative. * Split out ExecutableLocation. * Fixes for changes to ExecutableLocation. * Fix issues around Process on windows. * Improve comments. Kick CI. --- source/core/unix/slang-unix-process.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'source/core/unix') diff --git a/source/core/unix/slang-unix-process.cpp b/source/core/unix/slang-unix-process.cpp index 2c84ef08f..1f58f5725 100644 --- a/source/core/unix/slang-unix-process.cpp +++ b/source/core/unix/slang-unix-process.cpp @@ -355,8 +355,10 @@ static const int kCannotExecute = 126; { List argPtrs; + const auto& exe = commandLine.m_executableLocation; + // Add the command - argPtrs.add(commandLine.m_executable.getBuffer()); + argPtrs.add(exe.m_pathOrName.getBuffer()); // Add all the args - they don't need any explicit escaping for (auto arg : commandLine.m_args) @@ -413,9 +415,16 @@ static const int kCannotExecute = 126; // TODO(JS): Strictly speaking if m_executableType is 'Path' then we shouldn't be searching. Ie which // exec we use here should be dependent on the executable type. - // Path = execvp - // Filename = execv - ::execvp(argPtrs[0], (char* const*)&argPtrs[0]); + if (exe.m_type == ExecutableLocation::Type::Path) + { + // Use the specified path (ie don't search) + ::execv(argPtrs[0], (char* const*)&argPtrs[0]); + } + else + { + // Search for the executable + ::execvp(argPtrs[0], (char* const*)&argPtrs[0]); + } // If we get here, then `exec` failed -- cgit v1.2.3