Skip to content
  • Michael Crosby's avatar
    6bb653a6
    Return proper exit code for exec errors · 6bb653a6
    Michael Crosby authored
    
    
    Exec erros from the exec() syscall in the container's init should be
    treated as if the container ran but couldn't execute the process for the
    user instead of returning a libcontainer error as if it was an issue in
    the library.
    
    Before specifying different commands like `/etc`, `asldfkjasdlfj`, or
    `/alsdjfkasdlfj` would always return 1 on the command line with a
    libcontainer specific error message.  Now they return the correct
    message and exit status defined for unix processes.
    
    Example:
    
    ```bash
    root@deathstar:/containers/redis# runc start test
    exec: "/asdlfkjasldkfj": file does not exist
    root@deathstar:/containers/redis# echo $?
    127
    root@deathstar:/containers/redis# runc start test
    exec: "asdlfkjasldkfj": executable file not found in $PATH
    root@deathstar:/containers/redis# echo $?
    127
    root@deathstar:/containers/redis# runc start test
    exec: "/etc": permission denied
    root@deathstar:/containers/redis# echo $?
    126
    ```
    
    Signed-off-by: default avatarMichael Crosby <crosbymichael@gmail.com>
    6bb653a6
    Return proper exit code for exec errors
    Michael Crosby authored
    
    
    Exec erros from the exec() syscall in the container's init should be
    treated as if the container ran but couldn't execute the process for the
    user instead of returning a libcontainer error as if it was an issue in
    the library.
    
    Before specifying different commands like `/etc`, `asldfkjasdlfj`, or
    `/alsdjfkasdlfj` would always return 1 on the command line with a
    libcontainer specific error message.  Now they return the correct
    message and exit status defined for unix processes.
    
    Example:
    
    ```bash
    root@deathstar:/containers/redis# runc start test
    exec: "/asdlfkjasldkfj": file does not exist
    root@deathstar:/containers/redis# echo $?
    127
    root@deathstar:/containers/redis# runc start test
    exec: "asdlfkjasldkfj": executable file not found in $PATH
    root@deathstar:/containers/redis# echo $?
    127
    root@deathstar:/containers/redis# runc start test
    exec: "/etc": permission denied
    root@deathstar:/containers/redis# echo $?
    126
    ```
    
    Signed-off-by: default avatarMichael Crosby <crosbymichael@gmail.com>
Loading