[tip:tools/kvm] kvm tools: fix zombie reaping in guest/init.c

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

 



Commit-ID:  c1c92f20d733dcacb99a0fc6882d612331c488df
Gitweb:     http://git.kernel.org/tip/c1c92f20d733dcacb99a0fc6882d612331c488df
Author:     Marc Zyngier <marc.zyngier@xxxxxxx>
AuthorDate: Thu, 29 Nov 2012 19:40:00 +0000
Committer:  Pekka Enberg <penberg@xxxxxxxxxx>
CommitDate: Fri, 30 Nov 2012 10:38:04 +0200

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 <marc.zyngier@xxxxxxx>
Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx>
---
 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);
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux