From: Christian Brauner Date: Thu, 18 Mar 2021 11:11:32 +0000 (+0100) Subject: rexec: don't close stderr X-Git-Tag: lxc-5.0.0~255^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b75c1e611d984a2fe48236cd779b9edb1dfbecdd;p=thirdparty%2Flxc.git rexec: don't close stderr 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 --- diff --git a/src/lxc/rexec.c b/src/lxc/rexec.c index b0bb9050c..508d7eadc 100644 --- a/src/lxc/rexec.c +++ b/src/lxc/rexec.c @@ -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);