diff mbox

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

Message ID 1354218000-4891-1-git-send-email-marc.zyngier@arm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Marc Zyngier Nov. 29, 2012, 7:40 p.m. UTC
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@kernel.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
 tools/kvm/guest/init.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Pekka Enberg Nov. 30, 2012, 10:10 a.m. UTC | #1
On Thu, 29 Nov 2012, Marc Zyngier wrote:
> 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@kernel.org>
> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>

Applied, thanks Marc!
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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);