From 1ad95468d89447f9dba0f5fc7cee4ab2ca36f47e Mon Sep 17 00:00:00 2001 From: Marc Zyngier Date: Thu, 29 Nov 2012 19:40:00 +0000 Subject: [PATCH] kvm tools: fix zombie reaping in guest/init.c init.c is not very kind with processes that get reparented when their own parent die, leaving them hanging around. Looking at the code, it only seem to care about its own flesh and blood. Bad init. Teach it some basic zombie reaping skills. Signed-off-by: Marc Zyngier Signed-off-by: Pekka Enberg --- guest/init.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/guest/init.c b/guest/init.c index ece48fd..8c49a03 100644 --- a/guest/init.c +++ b/guest/init.c @@ -61,7 +61,11 @@ int main(int argc, char *argv[]) else run_process("/bin/sh"); } else { - waitpid(child, &status, 0); + pid_t corpse; + + do { + corpse = waitpid(-1, &status, 0); + } while (corpse != child); } reboot(LINUX_REBOOT_CMD_RESTART);