From: Richard Jones Date: Thu, 8 Apr 2010 18:06:00 +0000 (+0100) Subject: Don't kill self accidentally. X-Git-Tag: 1.3.2~15 X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=commitdiff_plain;h=dc5df3bfec706803e75a5f2454293db30e753249 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. --- 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);