Skip to content

Commit d38e8d3

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 c831593 commit d38e8d3

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
@@ -958,6 +958,7 @@ runShellCommand(CState *st, char *variable, char **argv, int argc)
958958
{
959959
if (!timer_exceeded)
960960
fprintf(stderr, "%s: cannot read the result\n", argv[0]);
961+
(void) pclose(fp);
961962
return false;
962963
}
963964
if (pclose(fp) < 0)

0 commit comments

Comments
 (0)