The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/6873

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) ===

From 1cea7fc523c0f1f09b1f24ff18d24510c00f2d1d Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brau...@ubuntu.com>
Date: Wed, 12 Feb 2020 09:27:21 +0100
Subject: [PATCH 1/2] shared: get_poll_revents(): handle EAGAIN in addition to
 EINTR

Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com>
---
 shared/util_linux_cgo.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/shared/util_linux_cgo.go b/shared/util_linux_cgo.go
index bcf7e4f1cb..1914ff1002 100644
--- a/shared/util_linux_cgo.go
+++ b/shared/util_linux_cgo.go
@@ -119,7 +119,7 @@ int get_poll_revents(int lfd, int timeout, int flags, int 
*revents, int *saved_e
 again:
        ret = poll(&pfd, 1, timeout);
        if (ret < 0) {
-               if (errno == EINTR)
+               if (errno == EINTR || errno == EAGAIN)
                        goto again;
 
                *saved_errno = errno;

From 0f39ee55f525f7359a1bde32f1c519fbcfd0e883 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brau...@ubuntu.com>
Date: Wed, 12 Feb 2020 10:41:21 +0100
Subject: [PATCH 2/2] lxc: send SIGTERM when there's no controlling terminal

This let's e.g. lxc exec -- su -l exit when the terminal is closed.

Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com>
---
 lxc/exec_unix.go | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lxc/exec_unix.go b/lxc/exec_unix.go
index 02429b9d36..91b62ad209 100644
--- a/lxc/exec_unix.go
+++ b/lxc/exec_unix.go
@@ -55,10 +55,17 @@ func (c *cmdExec) controlSocketHandler(control 
*websocket.Conn) {
                                return
                        }
                case unix.SIGHUP:
+                       file, err := os.OpenFile("/dev/tty", 
os.O_RDONLY|unix.O_NOCTTY|unix.O_NOFOLLOW|unix.O_CLOEXEC, 0666)
+                       if err == nil {
+                               file.Close()
+                               err = c.forwardSignal(control, unix.SIGHUP)
+                       } else {
+                               err = c.forwardSignal(control, unix.SIGTERM)
+                               sig = unix.SIGTERM
+                       }
                        logger.Debugf("Received '%s signal', forwarding to 
executing program.", sig)
-                       err := c.forwardSignal(control, unix.SIGHUP)
                        if err != nil {
-                               logger.Debugf("Failed to forward signal '%s'.", 
unix.SIGHUP)
+                               logger.Debugf("Failed to forward signal '%s'.", 
sig)
                                return
                        }
                case unix.SIGINT:
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to