Previous patch fixed behaviour with clone, so it's now safe just to set O_CLOEXEC flag on all inherited fd's.
Signed-off-by: Vladimir Smirnov <ci...@yandex-team.ru> --- src/lxc/start.c | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/lxc/start.c b/src/lxc/start.c index b8ceff6..6df70dc 100644 --- a/src/lxc/start.c +++ b/src/lxc/start.c @@ -154,6 +154,7 @@ int lxc_check_inherited(int fd_to_ignore) while (!readdir_r(dir, &dirent, &direntp)) { char procpath[64]; char path[PATH_MAX]; + int flags; if (!direntp) break; @@ -174,14 +175,24 @@ int lxc_check_inherited(int fd_to_ignore) /* * found inherited fd */ - ret = -1; + flags = fcntl(fd, F_GETFD); + if (flags < 0) { + ret = -1; + ERROR("failed to get flags, fd %d on %s", fd, path); + } + + fcntl(fd, F_SETFD, flags | FD_CLOEXEC); + if (flags < 0) { + ret = -1; + ERROR("failed to set CLOEXEC, fd %d on %s", fd, path); + } snprintf(procpath, sizeof(procpath), "/proc/self/fd/%d", fd); if (readlink(procpath, path, sizeof(path)) == -1) ERROR("readlink(%s) failed : %m", procpath); else - ERROR("inherited fd %d on %s", fd, path); + WARN("inherited fd %d on %s", fd, path); } if (closedir(dir)) -- 1.7.6 ------------------------------------------------------------------------------ EMC VNX: the world's simplest storage, starting under $10K The only unified storage solution that offers unified management Up to 160% more powerful than alternatives and 25% more efficient. Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev _______________________________________________ Lxc-devel mailing list Lxc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-devel