]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Don't raise error if container didn't sys_reboot
authorSerge Hallyn <serge.hallyn@canonical.com>
Tue, 7 Feb 2012 15:01:41 +0000 (09:01 -0600)
committerDaniel Lezcano <daniel.lezcano@free.fr>
Sun, 26 Feb 2012 09:44:40 +0000 (10:44 +0100)
Don't call it an error if a container exits without calling sys_reboot.
Particularly since that will almost always be the case with lxc-execute.
This fixes a regression introduced in commit
"49296e2ebfe7c5f9d6ebafbb54f5c5e56a0cc085: support proper container
reboot"

Signed-off-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
src/lxc/start.c

index 91ce5fa821771e0a33ceee3337e34ed5306d3c3f..4e631b230dc8e40b5996c26e3551b3b73a21a27a 100644 (file)
@@ -605,22 +605,25 @@ int __lxc_start(const char *name, struct lxc_conf *conf,
        while (waitpid(handler->pid, &status, 0) < 0 && errno == EINTR)
                continue;
 
-        if (!WIFSIGNALED(status)) {
-                printf("child process exited but was not signaled\n");
-                return -1;
-        }
-
-       switch(WTERMSIG(status)) {
-       case SIGINT: /* halt */
-               DEBUG("Container halting");
-               break;
-       case SIGHUP: /* reboot */
-               DEBUG("Container rebooting");
-               handler->conf->reboot = 1;
-               break;
-       default:
-               DEBUG("unknown exit status for init: %d\n", WTERMSIG(status));
-               break;
+       /*
+        * If the child process exited but was not signaled,
+        * it didn't call reboot.  This should mean it was an
+        * lxc-execute which simply exited.  In any case, treat
+        * it as a 'halt'
+        */
+        if (WIFSIGNALED(status)) {
+               switch(WTERMSIG(status)) {
+               case SIGINT: /* halt */
+                       DEBUG("Container halting");
+                       break;
+               case SIGHUP: /* reboot */
+                       DEBUG("Container rebooting");
+                       handler->conf->reboot = 1;
+                       break;
+               default:
+                       DEBUG("unknown exit status for init: %d\n", WTERMSIG(status));
+                       break;
+               }
         }
 
        err =  lxc_error_set_and_log(handler->pid, status);