forked from lix-project/lix
Don’t use execvp
when we know the path
This commit is contained in:
parent
02bd821f2e
commit
743232bf04
|
@ -662,7 +662,7 @@ struct CmdDevelop : Common, MixEnvironment
|
|||
}
|
||||
}
|
||||
|
||||
runProgramInStore(store, shell, args, buildEnvironment.getSystem());
|
||||
runProgramInStore(store, true, shell, args, buildEnvironment.getSystem());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ struct CmdFmt : SourceExprCommand {
|
|||
}
|
||||
}
|
||||
|
||||
runProgramInStore(store, app.program, programArgs);
|
||||
runProgramInStore(store, false, app.program, programArgs);
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ std::string chrootHelperName = "__run_in_chroot";
|
|||
namespace nix {
|
||||
|
||||
void runProgramInStore(ref<Store> store,
|
||||
bool search,
|
||||
const std::string & program,
|
||||
const Strings & args,
|
||||
std::optional<std::string_view> system)
|
||||
|
@ -58,7 +59,10 @@ void runProgramInStore(ref<Store> store,
|
|||
if (system)
|
||||
setPersonality(*system);
|
||||
|
||||
execvp(program.c_str(), stringsToCharPtrs(args).data());
|
||||
if (search)
|
||||
execvp(program.c_str(), stringsToCharPtrs(args).data());
|
||||
else
|
||||
execv(program.c_str(), stringsToCharPtrs(args).data());
|
||||
|
||||
throw SysError("unable to execute '%s'", program);
|
||||
}
|
||||
|
@ -132,7 +136,7 @@ struct CmdShell : InstallablesCommand, MixEnvironment
|
|||
Strings args;
|
||||
for (auto & arg : command) args.push_back(arg);
|
||||
|
||||
runProgramInStore(store, *command.begin(), args);
|
||||
runProgramInStore(store, true, *command.begin(), args);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -194,7 +198,7 @@ struct CmdRun : InstallableValueCommand
|
|||
Strings allArgs{app.program};
|
||||
for (auto & i : args) allArgs.push_back(i);
|
||||
|
||||
runProgramInStore(store, app.program, allArgs);
|
||||
runProgramInStore(store, false, app.program, allArgs);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
namespace nix {
|
||||
|
||||
void runProgramInStore(ref<Store> store,
|
||||
bool search,
|
||||
const std::string & program,
|
||||
const Strings & args,
|
||||
std::optional<std::string_view> system = std::nullopt);
|
||||
|
|
Loading…
Reference in a new issue