From 72851bb9ef0a6aef20141d0a13c36e5a1907a43a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Thu, 13 Oct 2011 13:47:58 +0200 Subject: [PATCH] virFDStream: close also given errfd (fd leak) In virFDStreamOpenFileInternal(), a errfd pipe is opened by virCommandRunAsync() and given to virFDStreamOpenInternal(). It seems virFDStream should close errfd, just like the other fd it is given. This fixes screenshots leaking FDs: http://bugzilla.redhat.com/show_bug.cgi?id=745761 --- src/fdstream.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/fdstream.c b/src/fdstream.c index b60162c6a1..841f979ddb 100644 --- a/src/fdstream.c +++ b/src/fdstream.c @@ -268,6 +268,10 @@ virFDStreamClose(virStreamPtr st) virCommandFree(fdst->cmd); fdst->cmd = NULL; } + + if (VIR_CLOSE(fdst->errfd) < 0) + VIR_DEBUG("ignoring failed close on fd %d", fdst->errfd); + st->privateData = NULL; if (fdst->dispatching) {