]> git.proxmox.com Git - mirror_lxc.git/commitdiff
attach: report standard shell exit codes
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 19 Sep 2018 07:15:36 +0000 (09:15 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 19 Sep 2018 09:26:37 +0000 (11:26 +0200)
POSIX mandates that on ENOEXEC 126 and on ENOENT 127 is supposed to be
reported.

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

index ffae98539181e49b58643b61e649a2e045664290..e109c4640f11fa8096b6b82446630bb875af255e 100644 (file)
@@ -1510,14 +1510,23 @@ int lxc_attach(const char *name, const char *lxcpath,
        _exit(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);
+       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)