[lxc-devel] [PATCH] Fix lxc-stop's -W / --nowait handling

Robert Vogelgesang vogel at users.sourceforge.net
Fri Jan 31 10:52:26 UTC 2014


Fix lxc-stop's -W / --nowait handling.

Note that this explicitely changes --nokill to imply waiting forever,
which was the implicit behaviour prior to my fix from today for
lxcapi_shutdown().

Signed-off-by: Robert Vogelgesang <vogel at users.sourceforge.net>

diff -up lxc-lxc-1.0.0.beta3/src/lxc/lxc_stop.c.orig lxc-lxc-1.0.0.beta3/src/lxc/lxc_stop.c
--- lxc-lxc-1.0.0.beta3/src/lxc/lxc_stop.c.orig	2014-01-30 19:07:20.940656328 +0100
+++ lxc-lxc-1.0.0.beta3/src/lxc/lxc_stop.c	2014-01-31 10:41:21.971956566 +0100
@@ -135,7 +135,6 @@ out:
 int main(int argc, char *argv[])
 {
 	struct lxc_container *c;
-	bool s;
 	int ret = 1;
 
 	if (lxc_arguments_parse(&my_args, argc, argv))
@@ -177,16 +176,13 @@ int main(int argc, char *argv[])
 	}
 
 	if (my_args.nokill)
+		my_args.timeout = -1;
+
+	if (my_args.nowait)
 		my_args.timeout = 0;
 
-	s = c->shutdown(c, my_args.timeout);
-	if (!s) {
-		if (!my_args.shutdown)
-			ret = c->wait(c, "STOPPED", -1) ? 0 : 1;
-		else
-			ret = 1; // fail
-	} else
-		ret = 0;
+	if (c->shutdown(c, my_args.timeout))
+		ret = 0; /* success */
 
 out:
 	lxc_container_put(c);


More information about the lxc-devel mailing list