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.

Cc: Pekka Enberg <[email protected]>
Signed-off-by: Marc Zyngier <[email protected]>
---
 tools/kvm/guest/init.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/kvm/guest/init.c b/tools/kvm/guest/init.c
index ece48fd..8c49a03 100644
--- a/tools/kvm/guest/init.c
+++ b/tools/kvm/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);
-- 
1.8.0.1


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to