]> git.proxmox.com Git - mirror_lxc.git/commitdiff
console: non-functional changes
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 26 Oct 2017 15:33:10 +0000 (17:33 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 6 Nov 2017 23:54:54 +0000 (00:54 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/console.c

index 659f86df507296eb39b0fd113e0d2ee43b5f9152..2d08366170b2a46d3182e963af1620693ae59134 100644 (file)
@@ -780,18 +780,16 @@ int lxc_console(struct lxc_container *c, int ttynum,
        istty = isatty(stdinfd);
        if (istty) {
                ret = lxc_setup_tios(stdinfd, &oldtios);
-               if (ret) {
-                       ERROR("failed to setup terminal properties");
+               if (ret < 0)
                        return -1;
-               }
        } else {
-               INFO("fd %d does not refer to a tty device", stdinfd);
+               INFO("File descriptor %d does not refer to a tty device", stdinfd);
        }
 
        ttyfd = lxc_cmd_console(c->name, &ttynum, &masterfd, c->config_path);
        if (ttyfd < 0) {
                ret = ttyfd;
-               goto err1;
+               goto restore_tios;
        }
 
        fprintf(stderr, "\n"
@@ -801,13 +799,13 @@ int lxc_console(struct lxc_container *c, int ttynum,
                        ttynum, 'a' + escape - 1);
 
        ret = setsid();
-       if (ret)
-               INFO("already group leader");
+       if (ret < 0)
+               TRACE("Process is already group leader");
 
        ts = lxc_console_sigwinch_init(stdinfd, masterfd);
        if (!ts) {
                ret = -1;
-               goto err2;
+               goto close_fds;
        }
        ts->escape = escape;
        ts->winch_proxy = c->name;
@@ -821,52 +819,57 @@ int lxc_console(struct lxc_container *c, int ttynum,
 
        ret = lxc_mainloop_open(&descr);
        if (ret) {
-               ERROR("failed to create mainloop");
-               goto err3;
+               ERROR("Failed to create mainloop");
+               goto sigwinch_fini;
        }
 
        if (ts->sigfd != -1) {
                ret = lxc_mainloop_add_handler(&descr, ts->sigfd,
-                               lxc_console_cb_sigwinch_fd, ts);
-               if (ret) {
-                       ERROR("failed to add handler for SIGWINCH fd");
-                       goto err4;
+                                              lxc_console_cb_sigwinch_fd, ts);
+               if (ret < 0) {
+                       ERROR("Failed to add SIGWINCH handler");
+                       goto close_mainloop;
                }
        }
 
        ret = lxc_mainloop_add_handler(&descr, ts->stdinfd,
                                       lxc_console_cb_tty_stdin, ts);
-       if (ret) {
-               ERROR("failed to add handler for stdinfd");
-               goto err4;
+       if (ret < 0) {
+               ERROR("Failed to add stdin handler");
+               goto close_mainloop;
        }
 
        ret = lxc_mainloop_add_handler(&descr, ts->masterfd,
                                       lxc_console_cb_tty_master, ts);
-       if (ret) {
-               ERROR("failed to add handler for masterfd");
-               goto err4;
+       if (ret < 0) {
+               ERROR("Failed to add master handler");
+               goto close_mainloop;
        }
 
        ret = lxc_mainloop(&descr, -1);
-       if (ret) {
-               ERROR("mainloop returned an error");
-               goto err4;
+       if (ret < 0) {
+               ERROR("The mainloop returned an error");
+               goto close_mainloop;
        }
 
        ret = 0;
 
-err4:
+close_mainloop:
        lxc_mainloop_close(&descr);
-err3:
+
+sigwinch_fini:
        lxc_console_sigwinch_fini(ts);
-err2:
+
+close_fds:
        close(masterfd);
        close(ttyfd);
-err1:
+
+restore_tios:
        if (istty) {
-               if (tcsetattr(stdinfd, TCSAFLUSH, &oldtios) < 0)
-                       WARN("failed to reset terminal properties: %s.", strerror(errno));
+               istty = tcsetattr(stdinfd, TCSAFLUSH, &oldtios);
+               if (istty < 0)
+                       WARN("%s - Failed to restore terminal properties",
+                            strerror(errno));
        }
 
        return ret;