]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
rexec: don't close stderr 3715/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 18 Mar 2021 11:11:32 +0000 (12:11 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 18 Mar 2021 11:12:05 +0000 (12:12 +0100)
Otherwise we'll fail to attach to containers later on.

Fixes: https://discuss.linuxcontainers.org/t/error-failed-to-retrieve-pid-of-executing-child-process
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/rexec.c

index b0bb9050cb6d2adb01a741e1afda6632efc0edcf..508d7eadc44a206a0c14225e7fe0a895c91c16da 100644 (file)
@@ -162,7 +162,7 @@ static void lxc_rexec_as_memfd(char **argv, char **envp, const char *memfd_name)
        if (execfd < 0)
                return;
 
-       ret = close_range(STDERR_FILENO, MAX_FILENO, CLOSE_RANGE_CLOEXEC);
+       ret = close_range(STDERR_FILENO + 1, MAX_FILENO, CLOSE_RANGE_CLOEXEC);
        if (ret && (errno != ENOSYS && errno != EINVAL))
                fprintf(stderr, "%m - Failed to mark all file descriptors as close-on-exec\n");
        fexecve(execfd, argv, envp);