From: Christian Brauner Date: Wed, 11 Jul 2018 21:43:38 +0000 (+0200) Subject: attach: use fd_cloexec() X-Git-Tag: lxc-3.1.0~211^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f62938a8a1f53711093c67ef6ebecc899c7651b;p=thirdparty%2Flxc.git attach: use fd_cloexec() Signed-off-by: Christian Brauner --- diff --git a/src/lxc/attach.c b/src/lxc/attach.c index 9b886af3c..2920872ff 100644 --- a/src/lxc/attach.c +++ b/src/lxc/attach.c @@ -930,16 +930,7 @@ static int attach_child_main(struct attach_clone_payload *payload) * here, ignore errors. */ for (fd = STDIN_FILENO; fd <= STDERR_FILENO; fd++) { - int flags; - - flags = fcntl(fd, F_GETFL); - if (flags < 0) - continue; - - if ((flags & FD_CLOEXEC) == 0) - continue; - - ret = fcntl(fd, F_SETFL, flags & ~FD_CLOEXEC); + ret = fd_cloexec(fd, false); if (ret < 0) { SYSERROR("Failed to clear FD_CLOEXEC from file descriptor %d", fd); goto on_error;