summaryrefslogtreecommitdiff
path: root/source/core/unix
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2021-12-03 11:45:01 -0500
committerGitHub <noreply@github.com>2021-12-03 11:45:01 -0500
commitda6be80f18014a3972eedf05099cd0066e9eae04 (patch)
tree687cb3853e1794b9478ee2a7b0503590f00f4669 /source/core/unix
parentf4b86ff23c825f5e776a401f89302bfcd358aae8 (diff)
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.
Diffstat (limited to 'source/core/unix')
-rw-r--r--source/core/unix/slang-unix-process.cpp17
1 files changed, 13 insertions, 4 deletions
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<char const*> 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