aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_ctl/pg_ctl.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 9da38c4e6f0..bae6c22a813 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -72,6 +72,7 @@ typedef enum
static bool do_wait = false;
static bool wait_set = false;
static int wait_seconds = DEFAULT_WAIT;
+static bool wait_seconds_arg = false;
static bool silent_mode = false;
static ShutdownMode shutdown_mode = FAST_MODE;
static int sig = SIGINT; /* default */
@@ -1431,7 +1432,8 @@ pgwin32_CommandLine(bool registration)
if (registration && do_wait)
appendPQExpBuffer(cmdLine, " -w");
- if (registration && wait_seconds != DEFAULT_WAIT)
+ /* Don't propagate a value from an environment variable. */
+ if (registration && wait_seconds_arg && wait_seconds != DEFAULT_WAIT)
appendPQExpBuffer(cmdLine, " -t %d", wait_seconds);
if (registration && silent_mode)
@@ -2128,6 +2130,7 @@ main(int argc, char **argv)
{NULL, 0, NULL, 0}
};
+ char *env_wait;
int option_index;
int c;
pgpid_t killproc = 0;
@@ -2178,6 +2181,10 @@ main(int argc, char **argv)
}
#endif
+ env_wait = getenv("PGCTLTIMEOUT");
+ if (env_wait != NULL)
+ wait_seconds = atoi(env_wait);
+
/*
* 'Action' can be before or after args so loop over both. Some
* getopt_long() implementations will reorder argv[] to place all flags
@@ -2255,6 +2262,7 @@ main(int argc, char **argv)
break;
case 't':
wait_seconds = atoi(optarg);
+ wait_seconds_arg = true;
break;
case 'U':
if (strchr(optarg, '\\'))