summaryrefslogtreecommitdiffstats
path: root/src/guestfs.c
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2010-04-08 19:06:00 +0100
committerRichard Jones <rjones@redhat.com>2010-04-08 19:06:00 +0100
commitdc5df3bfec706803e75a5f2454293db30e753249 (patch)
treef0a94a3d5a3130ce3c2e46e7a935bc3743e7b5ca /src/guestfs.c
parentfb4ec82d97f71963ea7f830cb0bc38abefcbac99 (diff)
downloadlibguestfs-dc5df3bfec706803e75a5f2454293db30e753249.tar.gz
libguestfs-dc5df3bfec706803e75a5f2454293db30e753249.tar.xz
libguestfs-dc5df3bfec706803e75a5f2454293db30e753249.zip
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.
Diffstat (limited to 'src/guestfs.c')
-rw-r--r--src/guestfs.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/guestfs.c b/src/guestfs.c
index ed514dce..d8c856a4 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);