diff --git a/src/container.c b/src/container.c index 6a1dd62..99b671c 100644 --- a/src/container.c +++ b/src/container.c @@ -624,8 +624,15 @@ static int hyper_container_init(void *data) execvp(container->exec.argv[0], container->exec.argv); perror("exec container command failed"); + /* the exit codes follow the `chroot` standard, + see docker/docs/reference/run.md#exit-status */ + if (errno == ENOENT) + _exit(127); + else if (errno == EACCES) + _exit(126); + fail: - _exit(-1); + _exit(125); } static int hyper_setup_pty(struct hyper_container *c) diff --git a/src/exec.c b/src/exec.c index 1ad68e8..2c0f121 100644 --- a/src/exec.c +++ b/src/exec.c @@ -590,10 +590,20 @@ static int hyper_do_exec_cmd(void *data) goto exit; } - if (execvp(exec->argv[0], exec->argv) < 0) + if (execvp(exec->argv[0], exec->argv) < 0) { perror("exec failed"); + + /* the exit codes follow the `chroot` standard, + see docker/docs/reference/run.md#exit-status */ + if (errno == ENOENT) + exit(127); + else if (errno == EACCES) + exit(126); + + } + exit: - _exit(ret); + _exit(125); out: hyper_send_type(arg->pipe[1], ret ? ERROR : READY); _exit(ret);