The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/7654
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === Signed-off-by: Stéphane Graber <[email protected]>
From 57252181b2ee2aef3a8f0e034bfff6c2dedb3169 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <[email protected]> Date: Tue, 14 Jul 2020 11:06:41 -0400 Subject: [PATCH] lxc/console: Disconnect on shutdown MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <[email protected]> --- lxc/console.go | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/lxc/console.go b/lxc/console.go index 7a8064a33d..cfc134311b 100644 --- a/lxc/console.go +++ b/lxc/console.go @@ -304,24 +304,33 @@ func (c *cmdConsole) vga(d lxd.InstanceServer, name string) error { }() // Use either spicy or remote-viewer if available. - remoteViewer, err := exec.LookPath("remote-viewer") - if err == nil { - _, err := shared.RunCommand(remoteViewer, fmt.Sprintf("spice+unix://%s", socket)) - if err != nil { - return err - } - } else { - spicy, err := exec.LookPath("spicy") - if err == nil { - _, err := shared.RunCommand(spicy, fmt.Sprintf("--uri=spice+unix://%s", socket)) - if err != nil { - return err - } + remoteViewer, _ := exec.LookPath("remote-viewer") + spicy, _ := exec.LookPath("spicy") + + if remoteViewer != "" || spicy != "" { + var cmd *exec.Cmd + if remoteViewer != "" { + cmd = exec.Command(remoteViewer, fmt.Sprintf("spice+unix://%s", socket)) } else { - fmt.Println(i18n.G("LXD automatically uses either spicy or remote-viewer when present.")) - fmt.Println(i18n.G("As neither could be found, the raw SPICE socket can be found at:")) - fmt.Printf(" %s\n", socket) + cmd = exec.Command(spicy, fmt.Sprintf("--uri=spice+unix://%s", socket)) } + + // Start the command. + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + cmd.Start() + + defer func() { + if cmd.Process == nil { + return + } + + cmd.Process.Kill() + }() + } else { + fmt.Println(i18n.G("LXD automatically uses either spicy or remote-viewer when present.")) + fmt.Println(i18n.G("As neither could be found, the raw SPICE socket can be found at:")) + fmt.Printf(" %s\n", socket) } // Wait for the operation to complete.
_______________________________________________ lxc-devel mailing list [email protected] http://lists.linuxcontainers.org/listinfo/lxc-devel
