aboutsummaryrefslogtreecommitdiff
path: root/src/nix/run.cc
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-03-04 06:28:55 +0100
committereldritch horrors <pennae@lix.systems>2024-03-04 07:11:25 +0100
commit94bf5a8018e0850964084947c1379ffe3fa2144d (patch)
tree3cab427f358a19955213b5d5848abeb3ff2ee479 /src/nix/run.cc
parent8505f963a1990566202b0fe60300f89c752ace86 (diff)
Merge pull request #9494 from sellout/nix-run-execv
Don’t use `execvp` when we know the path (cherry picked from commit dfa219d03b2277e61dde1c1ddddddff7411ef112) Change-Id: I2226340cebbe935e1f2fe10207daba69683c8cb3
Diffstat (limited to 'src/nix/run.cc')
-rw-r--r--src/nix/run.cc10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/nix/run.cc b/src/nix/run.cc
index 1baf299ab..1c16ce2c9 100644
--- a/src/nix/run.cc
+++ b/src/nix/run.cc
@@ -24,6 +24,7 @@ std::string chrootHelperName = "__run_in_chroot";
namespace nix {
void runProgramInStore(ref<Store> store,
+ UseSearchPath useSearchPath,
const std::string & program,
const Strings & args,
std::optional<std::string_view> system)
@@ -57,7 +58,10 @@ void runProgramInStore(ref<Store> store,
if (system)
setPersonality(*system);
- execvp(program.c_str(), stringsToCharPtrs(args).data());
+ if (useSearchPath == UseSearchPath::Use)
+ execvp(program.c_str(), stringsToCharPtrs(args).data());
+ else
+ execv(program.c_str(), stringsToCharPtrs(args).data());
throw SysError("unable to execute '%s'", program);
}
@@ -131,7 +135,7 @@ struct CmdShell : InstallablesCommand, MixEnvironment
Strings args;
for (auto & arg : command) args.push_back(arg);
- runProgramInStore(store, *command.begin(), args);
+ runProgramInStore(store, UseSearchPath::Use, *command.begin(), args);
}
};
@@ -193,7 +197,7 @@ struct CmdRun : InstallableValueCommand
Strings allArgs{app.program};
for (auto & i : args) allArgs.push_back(i);
- runProgramInStore(store, app.program, allArgs);
+ runProgramInStore(store, UseSearchPath::DontUse, app.program, allArgs);
}
};