diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c
index 2f6f56d..574f5b8 100644
*** a/src/test/regress/pg_regress.c
--- b/src/test/regress/pg_regress.c
*************** regression_main(int argc, char *argv[], 
*** 2185,2190 ****
--- 2185,2192 ----
  	if (temp_instance)
  	{
  		FILE	   *pg_conf;
+ 		const char *env_wait;
+ 		int			wait_seconds;
  
  		/*
  		 * Prepare the temp instance
*************** regression_main(int argc, char *argv[], 
*** 2335,2345 ****
  		}
  
  		/*
! 		 * Wait till postmaster is able to accept connections (normally only a
! 		 * second or so, but Cygwin is reportedly *much* slower).  Don't wait
! 		 * forever, however.
  		 */
! 		for (i = 0; i < 60; i++)
  		{
  			/* Done if psql succeeds */
  			if (system(buf2) == 0)
--- 2337,2359 ----
  		}
  
  		/*
! 		 * Wait till postmaster is able to accept connections; normally this
! 		 * is only a second or so, but Cygwin is reportedly *much* slower, and
! 		 * test builds using Valgrind or similar tools might be too.  Hence,
! 		 * allow the default timeout of 60 seconds to be overridden from the
! 		 * PGCTLTIMEOUT environment variable.
  		 */
! 		env_wait = getenv("PGCTLTIMEOUT");
! 		if (env_wait != NULL)
! 		{
! 			wait_seconds = atoi(env_wait);
! 			if (wait_seconds <= 0)
! 				wait_seconds = 60;
! 		}
! 		else
! 			wait_seconds = 60;
! 
! 		for (i = 0; i < wait_seconds; i++)
  		{
  			/* Done if psql succeeds */
  			if (system(buf2) == 0)
*************** regression_main(int argc, char *argv[], 
*** 2360,2368 ****
  
  			pg_usleep(1000000L);
  		}
! 		if (i >= 60)
  		{
! 			fprintf(stderr, _("\n%s: postmaster did not respond within 60 seconds\nExamine %s/log/postmaster.log for the reason\n"), progname, outputdir);
  
  			/*
  			 * If we get here, the postmaster is probably wedged somewhere in
--- 2374,2383 ----
  
  			pg_usleep(1000000L);
  		}
! 		if (i >= wait_seconds)
  		{
! 			fprintf(stderr, _("\n%s: postmaster did not respond within %d seconds\nExamine %s/log/postmaster.log for the reason\n"),
! 					progname, wait_seconds, outputdir);
  
  			/*
  			 * If we get here, the postmaster is probably wedged somewhere in
