summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/src/sgml/ref/pg_ctl-ref.sgml15
-rw-r--r--src/bin/pg_ctl/pg_ctl.c10
2 files changed, 23 insertions, 2 deletions
diff --git a/doc/src/sgml/ref/pg_ctl-ref.sgml b/doc/src/sgml/ref/pg_ctl-ref.sgml
index 37826e9c6c3..094f9b5d1fd 100644
--- a/doc/src/sgml/ref/pg_ctl-ref.sgml
+++ b/doc/src/sgml/ref/pg_ctl-ref.sgml
@@ -358,7 +358,9 @@ PostgreSQL documentation
<listitem>
<para>
The maximum number of seconds to wait when waiting for startup or
- shutdown to complete. The default is 60 seconds.
+ shutdown to complete. Defaults to the value of the
+ <envar>PGCTLTIMEOUT</> environment variable or, if not set, to 60
+ seconds.
</para>
</listitem>
</varlistentry>
@@ -466,6 +468,17 @@ PostgreSQL documentation
<variablelist>
<varlistentry>
+ <term><envar>PGCTLTIMEOUT</envar></term>
+
+ <listitem>
+ <para>
+ Default limit on the number of seconds to wait when waiting for startup
+ or shutdown to complete. If not set, the default is 60 seconds.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><envar>PGDATA</envar></term>
<listitem>
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index dded781b85a..1d155e0fbdd 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -80,6 +80,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 = SMART_MODE;
static int sig = SIGTERM; /* default */
@@ -1376,7 +1377,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)
@@ -2220,6 +2222,7 @@ main(int argc, char **argv)
{NULL, 0, NULL, 0}
};
+ char *env_wait;
int option_index;
int c;
pgpid_t killproc = 0;
@@ -2271,6 +2274,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
@@ -2340,6 +2347,7 @@ main(int argc, char **argv)
break;
case 't':
wait_seconds = atoi(optarg);
+ wait_seconds_arg = true;
break;
case 'U':
if (strchr(optarg, '\\'))