mirror of
https://github.com/postgres/postgres.git
synced 2025-06-14 18:42:34 +03:00
In pg_upgrade, improve popen() failure detection by checking for fgets()
failures.
This commit is contained in:
@ -754,11 +754,11 @@ check_for_support_lib(ClusterInfo *cluster)
|
|||||||
|
|
||||||
snprintf(cmd, sizeof(cmd), "\"%s/pg_config\" --pkglibdir", cluster->bindir);
|
snprintf(cmd, sizeof(cmd), "\"%s/pg_config\" --pkglibdir", cluster->bindir);
|
||||||
|
|
||||||
if ((output = popen(cmd, "r")) == NULL)
|
if ((output = popen(cmd, "r")) == NULL ||
|
||||||
pg_log(PG_FATAL, "Could not get pkglibdir data: %s\n",
|
fgets(libdir, sizeof(libdir), output) == NULL)
|
||||||
getErrorText(errno));
|
pg_log(PG_FATAL, "Could not get pkglibdir data using %s: %s\n",
|
||||||
|
cmd, getErrorText(errno));
|
||||||
|
|
||||||
fgets(libdir, sizeof(libdir), output);
|
|
||||||
|
|
||||||
pclose(output);
|
pclose(output);
|
||||||
|
|
||||||
@ -787,11 +787,10 @@ get_bin_version(ClusterInfo *cluster)
|
|||||||
|
|
||||||
snprintf(cmd, sizeof(cmd), "\"%s/pg_ctl\" --version", cluster->bindir);
|
snprintf(cmd, sizeof(cmd), "\"%s/pg_ctl\" --version", cluster->bindir);
|
||||||
|
|
||||||
if ((output = popen(cmd, "r")) == NULL)
|
if ((output = popen(cmd, "r")) == NULL ||
|
||||||
pg_log(PG_FATAL, "Could not get pg_ctl version data: %s\n",
|
fgets(cmd_output, sizeof(cmd_output), output) == NULL)
|
||||||
getErrorText(errno));
|
pg_log(PG_FATAL, "Could not get pg_ctl version data using %s: %s\n",
|
||||||
|
cmd, getErrorText(errno));
|
||||||
fgets(cmd_output, sizeof(cmd_output), output);
|
|
||||||
|
|
||||||
pclose(output);
|
pclose(output);
|
||||||
|
|
||||||
|
@ -109,8 +109,8 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
|||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
|
|
||||||
if ((output = popen(cmd, "r")) == NULL)
|
if ((output = popen(cmd, "r")) == NULL)
|
||||||
pg_log(PG_FATAL, "Could not get control data: %s\n",
|
pg_log(PG_FATAL, "Could not get control data using %s: %s\n",
|
||||||
getErrorText(errno));
|
cmd, getErrorText(errno));
|
||||||
|
|
||||||
/* Only pre-8.4 has these so if they are not set below we will check later */
|
/* Only pre-8.4 has these so if they are not set below we will check later */
|
||||||
cluster->controldata.lc_collate = NULL;
|
cluster->controldata.lc_collate = NULL;
|
||||||
|
Reference in New Issue
Block a user