arrange to return an appropriate status instead of -1 when the command is not found
This commit is contained in:
parent
116318f1f5
commit
84a73ae8cd
@ -540,10 +540,10 @@ int ExecCmd::startExec(const string& cmd, const vector<string>& args,
|
|||||||
// As we are going to use execve, not execvp, do the PATH thing.
|
// As we are going to use execve, not execvp, do the PATH thing.
|
||||||
string exe;
|
string exe;
|
||||||
if (!which(cmd, exe)) {
|
if (!which(cmd, exe)) {
|
||||||
LOGERR("ExecCmd::startExec: " << (cmd) << " not found\n");
|
LOGERR("ExecCmd::startExec: " << cmd << " not found\n");
|
||||||
free(argv);
|
free(argv);
|
||||||
free(envv);
|
free(envv);
|
||||||
return -1;
|
return 127 << 8;
|
||||||
}
|
}
|
||||||
//////////////////////////////// End vfork child prepare section.
|
//////////////////////////////// End vfork child prepare section.
|
||||||
|
|
||||||
@ -765,9 +765,9 @@ private:
|
|||||||
int ExecCmd::doexec(const string& cmd, const vector<string>& args,
|
int ExecCmd::doexec(const string& cmd, const vector<string>& args,
|
||||||
const string *input, string *output)
|
const string *input, string *output)
|
||||||
{
|
{
|
||||||
|
int status = startExec(cmd, args, input != 0, output != 0);
|
||||||
if (startExec(cmd, args, input != 0, output != 0) < 0) {
|
if (status) {
|
||||||
return -1;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup in case we return early
|
// Cleanup in case we return early
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user