]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
attach: report standard shell exit codes
authorChristian Brauner <christian.brauner@ubuntu.com>
Mon, 10 Dec 2018 15:30:46 +0000 (16:30 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 10 Dec 2018 15:30:46 +0000 (16:30 +0100)
custom backport

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/attach.c

index 9d36bfa1de5ca4f40ffddbc8e20b3bd1e9df9038..08bb48affdcc99ce4dfc1c41623c93d46ecfbf80 100644 (file)
@@ -1403,13 +1403,25 @@ int lxc_attach(const char *name, const char *lxcpath,
        rexit(0);
 }
 
-int lxc_attach_run_command(voidpayload)
+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);
-       SYSERROR("Failed to exec \"%s\".", cmd->program);
-       return -1;
+       ret = execvp(cmd->program, cmd->argv);
+       if (ret < 0) {
+               switch (errno) {
+               case ENOEXEC:
+                       ret = 126;
+                       break;
+               case ENOENT:
+                       ret = 127;
+                       break;
+               }
+       }
+
+       SYSERROR("Failed to exec \"%s\"", cmd->program);
+       return ret;
 }
 
 int lxc_attach_run_shell(void* payload)