]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
attach: use fd_cloexec()
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 11 Jul 2018 21:43:38 +0000 (23:43 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 12 Jul 2018 11:06:45 +0000 (13:06 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/attach.c

index 9b886af3c5fb5b048396b8b4b42b1955336a5232..2920872ffd5bbc538590ee0af154c505a5392151 100644 (file)
@@ -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;