[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lxc-devel
Subject:    [lxc-devel] [lxd/master] exec: kill forkexec on abnormal websocket closure
From:       brauner on Github <lxc-bot () linuxcontainers ! org>
Date:       2017-02-27 21:05:17
Message-ID: 20170227210517.AD061407F7 () mailman01 ! srv ! dcmtl ! stgraber ! net
[Download RAW message or body]

[Attachment #2 (text/x-mailbox)]

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

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: Christian Brauner <christian.brauner@ubuntu.com>

[Attachment #3 (text/plain)]

From f010392bd1bf22c76ad11751e9faf29830f7be5f Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner@ubuntu.com>
Date: Mon, 27 Feb 2017 21:32:47 +0100
Subject: [PATCH] exec: kill forkexec on abnormal websocket closure

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
---
 lxd/container_exec.go | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/lxd/container_exec.go b/lxd/container_exec.go
index 4e2ab6d..5e266ba 100644
--- a/lxd/container_exec.go
+++ b/lxd/container_exec.go
@@ -159,7 +159,18 @@ func (s *execWs) Do(op *operation) error {
 				}
 
 				if err != nil {
-					shared.LogDebugf("Got error getting next reader %s", err)
+					if er, ok := err.(*websocket.CloseError); ok {
+						if er.Code != websocket.CloseAbnormalClosure {
+							shared.LogDebugf("Got error getting next reader %s", err)
+							break
+						}
+
+						// If an abnormal closure occured, kill the attached process.
+						err := syscall.Kill(attachedChildPid, syscall.SIGKILL)
+						if err != nil {
+							shared.LogErrorf("Failed to send SIGKILL to pid %d.", attachedChildPid)
+						}
+					}
 					break
 				}
 

[Attachment #4 (text/plain)]

_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic