Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9ae8ebe

Browse files
committed
Improve reporting of error situations in find_other_exec().
This function suppressed any stderr output from the called program, whichis unnecessary in the normal case and unhelpful in error cases. It alsogave a rather opaque message along the lines of "fgets failure: Success"in case the called program failed to return anything on stdout. Sincewe've seen multiple reports of people not understanding what's wrong whenpg_ctl reports this, improve the message.Back-patch to all active branches.
1 parentc9a2532 commit9ae8ebe

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
returnNULL;
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
returnNULL;
363371
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp