summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-11-18 23:47:09 +0100
committerLennart Poettering <lennart@poettering.net>2016-11-22 13:35:09 +0100
commit6a0f896b97ab4f744bf4404011f8ac9d2f978443 (patch)
treea1671612110c8e193ce05d899d95835c3aca003a
parentb6e953f24cadd03d461b4b886a1b6a8acdd2bb2d (diff)
nspawn: try to wait for the container PID 1 to exit, before we exit
Let's make the shutdown logic synchronous, so that there's a better chance to detach the loopback device after use.
-rw-r--r--src/nspawn/nspawn.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index 0ca0b2f4c8..8e4b94ef82 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -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);