Skip to content

Commit 6c75384

Browse files
committed
Fix file descriptor leak after failure of a \setshell command in pgbench.
If the called command fails to return data, runShellCommand forgot to pclose() the pipe before returning. This is fairly harmless in the current code, because pgbench would then abandon further processing of that client thread; so no more than nclients descriptors could be leaked this way. But it's not hard to imagine future improvements whereby that wouldn't be true. In any case, it's sloppy coding, so patch all branches. Found by Coverity.
1 parent ce864d3 commit 6c75384

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

contrib/pgbench/pgbench.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,7 @@ runShellCommand(CState *st, char *variable, char **argv, int argc)
863863
{
864864
if (!timer_exceeded)
865865
fprintf(stderr, "%s: cannot read the result\n", argv[0]);
866+
(void) pclose(fp);
866867
return false;
867868
}
868869
if (pclose(fp) < 0)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy