Skip to content

Commit 961df18

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 662eebd commit 961df18

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
@@ -691,6 +691,7 @@ runShellCommand(CState *st, char *variable, char **argv, int argc)
691691
{
692692
if (!timer_exceeded)
693693
fprintf(stderr, "%s: cannot read the result\n", argv[0]);
694+
(void) pclose(fp);
694695
return false;
695696
}
696697
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