The caller of run_command does not directly get access to the errno from exec, because it happens in the forked child. However, knowing the specific reason for an exec failure can help the parent respond better or produce better error messages. We already propagate ENOENT to the parent via exit code 127. Let's do the same for EACCES with exit code 126, which is already used by bash to indicate the same thing. Signed-off-by: Jeff King <peff@xxxxxxxx> --- Actually, there is a slight bending of the truth in the commit message. bash implements its own execvp, and it will only return 126/EACCES if a file is found via stat(), but is not executable. If there is an inaccessible directory in the PATH (meaning that stat() will fail), it will silently convert that to 127/ENOENT. run-command.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/run-command.c b/run-command.c index 1db8abf..e303beb 100644 --- a/run-command.c +++ b/run-command.c @@ -185,6 +185,10 @@ static int wait_or_whine(pid_t pid, const char *argv0, int silent_exec_failure) code = -1; failed_errno = ENOENT; } + else if (code == 126) { + code = -1; + failed_errno = EACCES; + } } else { error("waitpid is confused (%s)", argv0); } @@ -346,6 +350,11 @@ fail_pipe: error("cannot run %s: %s", cmd->argv[0], strerror(ENOENT)); exit(127); + } else if (errno == EACCES) { + if (!cmd->silent_exec_failure) + error("cannot run %s: %s", cmd->argv[0], + strerror(errno)); + exit(126); } else { die_errno("cannot exec '%s'", cmd->argv[0]); } -- 1.7.9.5.5.g9b709b -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html