From 3cbf5d5f76845bc094ee648770d8a8ce3731d6a3 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Tue, 12 Jul 2011 12:07:01 -0600 Subject: [PATCH] fdstream: avoid child process leak on error By requesting the pid in virCommandRunAsync, fdstream was claiming that it would manually wait for the process. But on the failure path, the child process was being leaked. * src/fdstream.c (virFDStreamOpenFileInternal): Auto-reap child. --- src/fdstream.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/fdstream.c b/src/fdstream.c index c9fe2f33bf..4dbe4a3ef7 100644 --- a/src/fdstream.c +++ b/src/fdstream.c @@ -31,7 +31,6 @@ # include #endif #include -#include #include "fdstream.h" #include "virterror_internal.h" @@ -514,7 +513,6 @@ virFDStreamOpenFileInternal(virStreamPtr st, struct stat sb; virCommandPtr cmd = NULL; int errfd = -1; - pid_t pid = 0; VIR_DEBUG("st=%p path=%s flags=%x offset=%llu length=%llu mode=%o delete=%d", st, path, flags, offset, length, mode, delete); @@ -588,7 +586,7 @@ virFDStreamOpenFileInternal(virStreamPtr st, } virCommandSetErrorFD(cmd, &errfd); - if (virCommandRunAsync(cmd, &pid) < 0) + if (virCommandRunAsync(cmd, NULL) < 0) goto error; VIR_FORCE_CLOSE(childfd); @@ -611,10 +609,6 @@ virFDStreamOpenFileInternal(virStreamPtr st, return 0; error: -#ifndef WIN32 - if (pid) - kill(SIGTERM, pid); -#endif virCommandFree(cmd); VIR_FORCE_CLOSE(fds[0]); VIR_FORCE_CLOSE(fds[1]); -- GitLab