[lxc-devel] [go-lxc/v2] Do not suppress stderr if Execute command exits nonzero
stgraber on Github
lxc-bot at linuxcontainers.org
Sat May 26 22:29:49 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 406 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180526/b2c8ee57/attachment.bin>
-------------- next part --------------
From 405efdef0877a799e6c682f1bf67a1af5485d167 Mon Sep 17 00:00:00 2001
From: Seth Moore <sethdmoore at gmail.com>
Date: Mon, 18 Apr 2016 22:01:19 -0400
Subject: [PATCH] Do not suppress stderr if Execute command exits nonzero
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Seth Moore <sethdmoore at gmail.com>
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
container.go | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/container.go b/container.go
index cc3b680..93f6203 100644
--- a/container.go
+++ b/container.go
@@ -527,6 +527,11 @@ func (c *Container) Execute(args ...string) ([]byte, error) {
// go-nuts thread: https://groups.google.com/forum/#!msg/golang-nuts/h9GbvfYv83w/5Ly_jvOr86wJ
output, err := exec.Command(cargs[0], cargs[1:]...).CombinedOutput()
if err != nil {
+ // Do not suppress stderr if the exit code != 0. Return with err.
+ if len(output) > 1 {
+ return output, ErrExecuteFailed
+ }
+
return nil, ErrExecuteFailed
}
More information about the lxc-devel
mailing list