[lxc-devel] [lxc/master] tools: use correct exit code for lxc-stop

brauner on Github lxc-bot at linuxcontainers.org
Sun Oct 30 17:27:00 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 481 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20161030/59dff75a/attachment.bin>
-------------- next part --------------
From dfef27a5a1d80a2d3e7483390728c060e304d14f Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at canonical.com>
Date: Sun, 30 Oct 2016 18:24:15 +0100
Subject: [PATCH] tools: use correct exit code for lxc-stop

When the container is already running our manpage promises to exit with 2.
Let's make it so.

Signed-off-by: Christian Brauner <christian.brauner at canonical.com>
---
 src/lxc/tools/lxc_stop.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/lxc/tools/lxc_stop.c b/src/lxc/tools/lxc_stop.c
index 498aac1..d87ed16 100644
--- a/src/lxc/tools/lxc_stop.c
+++ b/src/lxc/tools/lxc_stop.c
@@ -226,7 +226,10 @@ int main(int argc, char *argv[])
 
 	if (!c->is_running(c)) {
 		fprintf(stderr, "%s is not running\n", c->name);
-		ret = EXIT_FAILURE;
+		/* Per our manpage we need to exit with exit code:
+		 * 2: The specified container exists but was not running.
+		 */
+		ret = 2;
 		goto out;
 	}
 


More information about the lxc-devel mailing list