]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
nspawn: try to wait for the container PID 1 to exit, before we exit
authorLennart Poettering <lennart@poettering.net>
Fri, 18 Nov 2016 22:47:09 +0000 (23:47 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 22 Nov 2016 12:35:09 +0000 (13:35 +0100)
Let's make the shutdown logic synchronous, so that there's a better chance to
detach the loopback device after use.

src/nspawn/nspawn.c

index 0ca0b2f4c88f4af7262330e25f22f5cf169e630a..8e4b94ef82e62b444afbac747a527465d966b0eb 100644 (file)
@@ -4349,8 +4349,13 @@ finish:
                 kill(pid, SIGKILL);
 
         /* Try to flush whatever is still queued in the pty */
-        if (master >= 0)
+        if (master >= 0) {
                 (void) copy_bytes(master, STDOUT_FILENO, (uint64_t) -1, false);
+                master = safe_close(master);
+        }
+
+        if (pid > 0)
+                (void) wait_for_terminate(pid, NULL);
 
         loop_remove(loop_nr, &image_fd);