From 06346bb04a00e5fa70d5ee221f4cb70201b8dd56 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Wed, 19 Sep 2018 09:15:36 +0200 Subject: [PATCH] attach: report standard shell exit codes POSIX mandates that on ENOEXEC 126 and on ENOENT 127 is supposed to be reported. Signed-off-by: Christian Brauner --- src/lxc/attach.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/lxc/attach.c b/src/lxc/attach.c index ffae98539..e109c4640 100644 --- a/src/lxc/attach.c +++ b/src/lxc/attach.c @@ -1510,14 +1510,23 @@ int lxc_attach(const char *name, const char *lxcpath, _exit(0); } -int lxc_attach_run_command(void* payload) +int lxc_attach_run_command(void *payload) { - lxc_attach_command_t* cmd = (lxc_attach_command_t*)payload; + int ret = -1; + lxc_attach_command_t *cmd = payload; - execvp(cmd->program, cmd->argv); + ret = execvp(cmd->program, cmd->argv); + if (ret < 0) { + switch (errno) { + case ENOEXEC: + ret = 126; + case ENOENT: + ret = 127; + } + } SYSERROR("Failed to exec \"%s\"", cmd->program); - return -1; + return ret; } int lxc_attach_run_shell(void* payload)