[lxc-devel] [lxd/master] exec: kill forkexec on abnormal websocket closure
brauner on Github
lxc-bot at linuxcontainers.org
Mon Feb 27 21:05:16 UTC 2017
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 364 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170227/41852cdb/attachment.bin>
-------------- next part --------------
From f010392bd1bf22c76ad11751e9faf29830f7be5f Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at 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 at 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
}
More information about the lxc-devel
mailing list