]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
start: don't unconditionally open("/dev/null")
authorChristian Brauner <christian.brauner@ubuntu.com>
Mon, 9 Jul 2018 12:28:57 +0000 (14:28 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 10 Dec 2018 13:47:53 +0000 (14:47 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/start.c

index a12e2ecfd6778506b0464df9264c908b96ea471f..209904c01fae3d0840040204132cdf2022411602 100644 (file)
@@ -1287,23 +1287,18 @@ static int do_start(void *data)
 
        close(handler->sigfd);
 
-       if (devnull_fd < 0) {
-               devnull_fd = open_devnull();
-
-               if (devnull_fd < 0)
-                       goto out_warn_father;
-       }
+       if (handler->conf->console.slave < 0 && handler->backgrounded) {
+               if (devnull_fd < 0) {
+                       devnull_fd = open_devnull();
+                       if (devnull_fd < 0)
+                               goto out_warn_father;
+               }
 
-       if (handler->conf->console.slave < 0 && handler->backgrounded)
-               if (set_stdfds(devnull_fd) < 0) {
-                       ERROR("Failed to redirect std{in,out,err} to "
-                             "\"/dev/null\"");
+               ret = set_stdfds(devnull_fd);
+               if (ret < 0) {
+                       ERROR("Failed to redirect std{in,out,err} to \"/dev/null\"");
                        goto out_warn_father;
                }
-
-       if (devnull_fd >= 0) {
-               close(devnull_fd);
-               devnull_fd = -1;
        }
 
        setsid();