Skip to content

Commit 3b750ec

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 ea78d13 commit 3b750ec

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
@@ -828,6 +828,7 @@ runShellCommand(CState *st, char *variable, char **argv, int argc)
828828
{
829829
if (!timer_exceeded)
830830
fprintf(stderr, "%s: cannot read the result\n", argv[0]);
831+
(void) pclose(fp);
831832
return false;
832833
}
833834
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