Print error if child process cannot access monitor script file
This commit is contained in:
@ -108,7 +108,7 @@ std::unique_ptr<ExternalCmd> ExternalCmd::create(const string& argstr, int timeo
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MXS_ERROR("Cannot execute file '%s'. Missing execution permissions.", cmdname);
|
MXS_ERROR("Cannot execute file '%s'. Missing execution permission.", cmdname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -239,8 +239,21 @@ int ExternalCmd::externcmd_execute()
|
|||||||
// Execute the command
|
// Execute the command
|
||||||
execvp(cmdname, argvec);
|
execvp(cmdname, argvec);
|
||||||
|
|
||||||
// Close the write end of the pipe and exit
|
// This is only reached if execvp failed to start the command. Print to the standard error stream.
|
||||||
close(fd[1]);
|
// The message will be caught by the parent process.
|
||||||
|
int error = errno;
|
||||||
|
if (error == EACCES)
|
||||||
|
{
|
||||||
|
// This is the most likely error, handle separately.
|
||||||
|
fprintf(stderr, "error: Cannot execute file. File cannot be accessed or it is missing "
|
||||||
|
"execution permission.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "error: Cannot execute file. 'execvp' error: '%s'", strerror(error));
|
||||||
|
}
|
||||||
|
fflush(stderr);
|
||||||
|
// Exit with error. The write end of the pipe should close by itself.
|
||||||
_exit(1);
|
_exit(1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user