diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index 9ea3d741112ec21b011729c425b063411e8f1e7d..898b6f72a29e52007c5918ce3c2651b63a8b2d35 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.207 2005/10/15 02:49:12 momjian Exp $
+ *	  $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.208 2005/10/20 20:05:44 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -359,6 +359,8 @@ BootstrapMain(int argc, char *argv[])
 	{
 		if (!SelectConfigFiles(userDoption, progname))
 			proc_exit(1);
+		/* If timezone is not set, determine what the OS uses */
+		pg_timezone_initialize();
 	}
 
 	/* Validate we have been given a reasonable-looking DataDir */
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index 527677e0e752d5ebe436fe0e4515b3435f43c52e..ad6477a372d34004a6bc5d8ee37c6f3c3187381d 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -37,7 +37,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.470 2005/10/17 16:24:19 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.471 2005/10/20 20:05:44 tgl Exp $
  *
  * NOTES
  *
@@ -626,7 +626,8 @@ PostmasterMain(int argc, char *argv[])
 	}
 
 	/*
-	 * Other one-time internal sanity checks can go here.
+	 * Other one-time internal sanity checks can go here, if they are fast.
+	 * (Put any slow processing further down, after postmaster.pid creation.)
 	 */
 	if (!CheckDateTokenTables())
 	{
@@ -660,21 +661,6 @@ PostmasterMain(int argc, char *argv[])
 			 (errmsg_internal("-----------------------------------------")));
 	}
 
-	/*
-	 * Initialize SSL library, if specified.
-	 */
-#ifdef USE_SSL
-	if (EnableSSL)
-		secure_initialize();
-#endif
-
-	/*
-	 * process any libraries that should be preloaded and optionally
-	 * pre-initialized
-	 */
-	if (preload_libraries_string)
-		process_preload_libraries(preload_libraries_string);
-
 	/*
 	 * Fork away from controlling terminal, if -S specified.
 	 *
@@ -695,6 +681,30 @@ PostmasterMain(int argc, char *argv[])
 	 */
 	CreateDataDirLockFile(true);
 
+	/*
+	 * If timezone is not set, determine what the OS uses.  (In theory this
+	 * should be done during GUC initialization, but because it can take as
+	 * much as several seconds, we delay it until after we've created the
+	 * postmaster.pid file.  This prevents problems with boot scripts that
+	 * expect the pidfile to appear quickly.)
+	 */
+	pg_timezone_initialize();
+
+	/*
+	 * Initialize SSL library, if specified.
+	 */
+#ifdef USE_SSL
+	if (EnableSSL)
+		secure_initialize();
+#endif
+
+	/*
+	 * process any libraries that should be preloaded and optionally
+	 * pre-initialized
+	 */
+	if (preload_libraries_string)
+		process_preload_libraries(preload_libraries_string);
+
 	/*
 	 * Remove old temporary files.	At this point there can be no other
 	 * Postgres processes running in this directory, so this should be safe.
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index 93bcc936602f42868aef85760105fc85f869c497..77a85f27e4f3fc882b0343a67a7095f50cab176b 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.466 2005/10/15 02:49:27 momjian Exp $
+ *	  $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.467 2005/10/20 20:05:45 tgl Exp $
  *
  * NOTES
  *	  this is the "main" module of the postgres backend and
@@ -2760,6 +2760,8 @@ PostgresMain(int argc, char *argv[], const char *username)
 	{
 		if (!SelectConfigFiles(userDoption, argv[0]))
 			proc_exit(1);
+		/* If timezone is not set, determine what the OS uses */
+		pg_timezone_initialize();
 	}
 
 	/*
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 5b2a6903fd123909661b1685a34d1c9c67c29fa0..30b5db8b9a63fe7662d694aa403a6ea38ec84756 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -10,7 +10,7 @@
  * Written by Peter Eisentraut <peter_e@gmx.net>.
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.294 2005/10/16 18:26:00 momjian Exp $
+ *	  $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.295 2005/10/20 20:05:45 tgl Exp $
  *
  *--------------------------------------------------------------------
  */
@@ -2846,9 +2846,6 @@ SelectConfigFiles(const char *userDoption, const char *progname)
 
 	free(configdir);
 
-	/* If timezone is not set, determine what the OS uses */
-	pg_timezone_initialize();
-
 	return true;
 }