From dc5df3bfec706803e75a5f2454293db30e753249 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Thu, 8 Apr 2010 19:06:00 +0100 Subject: [PATCH] Don't kill self accidentally. Always check that pid > 0 before calling kill (pid, 9). The issue was that sometimes pid == 0, and this ends up killing ourselves. --- src/guestfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/guestfs.c b/src/guestfs.c index ed514dc..d8c856a 100644 --- a/src/guestfs.c +++ b/src/guestfs.c @@ -1500,7 +1500,7 @@ guestfs__launch (guestfs_h *g) close (wfd[1]); close (rfd[0]); } - kill (g->pid, 9); + if (g->pid > 0) kill (g->pid, 9); if (g->recoverypid > 0) kill (g->recoverypid, 9); waitpid (g->pid, NULL, 0); if (g->recoverypid > 0) waitpid (g->recoverypid, NULL, 0); @@ -1848,7 +1848,7 @@ guestfs__kill_subprocess (guestfs_h *g) if (g->verbose) fprintf (stderr, "sending SIGTERM to process %d\n", g->pid); - kill (g->pid, SIGTERM); + if (g->pid > 0) kill (g->pid, SIGTERM); if (g->recoverypid > 0) kill (g->recoverypid, 9); return 0; @@ -1999,7 +1999,7 @@ child_cleanup (guestfs_h *g) if (g->verbose) fprintf (stderr, "child_cleanup: %p: child process died\n", g); - /*kill (g->pid, SIGTERM);*/ + /*if (g->pid > 0) kill (g->pid, SIGTERM);*/ if (g->recoverypid > 0) kill (g->recoverypid, 9); waitpid (g->pid, NULL, 0); if (g->recoverypid > 0) waitpid (g->recoverypid, NULL, 0); -- 1.8.3.1