Skip to content

Commit 9ae8ebe

Browse files
committed
Improve reporting of error situations in find_other_exec().
This function suppressed any stderr output from the called program, which is unnecessary in the normal case and unhelpful in error cases. It also gave a rather opaque message along the lines of "fgets failure: Success" in case the called program failed to return anything on stdout. Since we've seen multiple reports of people not understanding what's wrong when pg_ctl reports this, improve the message. Back-patch to all active branches.
1 parent c9a2532 commit 9ae8ebe

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/port/exec.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ find_other_exec(const char *argv0, const char *target,
322322
if (validate_exec(retpath) != 0)
323323
return -1;
324324

325-
snprintf(cmd, sizeof(cmd), "\"%s\" -V 2>%s", retpath, DEVNULL);
325+
snprintf(cmd, sizeof(cmd), "\"%s\" -V", retpath);
326326

327327
if (!pipe_read_line(cmd, line, sizeof(line)))
328328
return -1;
@@ -352,12 +352,20 @@ pipe_read_line(char *cmd, char *line, int maxsize)
352352
fflush(stdout);
353353
fflush(stderr);
354354

355+
errno = 0;
355356
if ((pgver = popen(cmd, "r")) == NULL)
357+
{
358+
perror("popen failure");
356359
return NULL;
360+
}
357361

362+
errno = 0;
358363
if (fgets(line, maxsize, pgver) == NULL)
359364
{
360-
perror("fgets failure");
365+
if (feof(pgver))
366+
fprintf(stderr, "no data was returned by command \"%s\"\n", cmd);
367+
else
368+
perror("fgets failure");
361369
pclose(pgver); /* no error checking */
362370
return NULL;
363371
}

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