[lxc-devel] [lxd/master] exec: report -1 (255) on signal exit

brauner on Github lxc-bot at linuxcontainers.org
Wed Jan 18 23:11:57 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 416 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170118/67b5cc23/attachment.bin>
-------------- next part --------------
From b61cd753b7d6c78ee72b0bf05ef8134c566db087 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Thu, 19 Jan 2017 00:09:18 +0100
Subject: [PATCH] exec: report -1 (255) on signal exit

This makes exec behave even more similar to ssh.

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 lxd/container_exec.go | 4 ++--
 lxd/main_forkexec.go  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lxd/container_exec.go b/lxd/container_exec.go
index 60c15f2..73c0b27 100644
--- a/lxd/container_exec.go
+++ b/lxd/container_exec.go
@@ -195,7 +195,7 @@ func (s *execWs) Do(op *operation) error {
 						shared.LogDebugf("Failed forwarding signal '%s' to PID %d.", command.Signal, attachedChildPid)
 						continue
 					}
-					shared.LogDebugf("Forwarded signal '%s' to PID %d.", command.Signal, attachedChildPid)
+					shared.LogDebugf("Forwarded signal '%d' to PID %d.", command.Signal, attachedChildPid)
 				}
 			}
 		}()
@@ -287,7 +287,7 @@ func (s *execWs) Do(op *operation) error {
 		// lxc exec foo reboot receives SIGTERM and status.Exitstats()
 		// would report -1.
 		if status.Signaled() {
-			return finisher(0, nil)
+			return finisher(-1, nil)
 		}
 	}
 
diff --git a/lxd/main_forkexec.go b/lxd/main_forkexec.go
index b9c6cbb..7c7391b 100644
--- a/lxd/main_forkexec.go
+++ b/lxd/main_forkexec.go
@@ -127,7 +127,7 @@ func cmdForkExec(args []string) (int, error) {
 		// lxc exec foo reboot receives SIGTERM and exCode.Exitstats()
 		// would report -1.
 		if exCode.Signaled() {
-			return 0, nil
+			return -1, nil
 		}
 	}
 


More information about the lxc-devel mailing list