[PATCH] kvm-tool: fix zombie reaping in guest/init.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <penberg@xxxxxxxxxx>
Signed-off-by: Marc Zyngier <marc.zyngier@xxxxxxx>
---
 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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux