44 * Stub main() routine for the postgres executable.
55 *
66 * This does some essential startup tasks for any incarnation of postgres
7- * (postmaster, standalone backend, or standalone bootstrap mode) and then
8- * dispatches to the proper FooMain() routine for the incarnation.
7+ * (postmaster, standalone backend, standalone bootstrap process, or a
8+ * separately exec'd child of a postmaster) and then dispatches to the
9+ * proper FooMain() routine for the incarnation.
910 *
1011 *
1112 * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
@@ -54,7 +55,9 @@ static void check_root(const char *progname);
5455static char * get_current_username (const char * progname );
5556
5657
57-
58+ /*
59+ * Any Postgres server process begins execution here.
60+ */
5861int
5962main (int argc ,char * argv [])
6063{
@@ -192,10 +195,10 @@ main(int argc, char *argv[])
192195
193196/*
194197 * Place platform-specific startup hacks here.This is the right
195- * place to put code that must be executed early in launch ofeither a
196- *postmaster, a standalone backend, or a standalone bootstrap run.
197- *Note that this code will NOT be executed when abackend or
198- *sub-bootstrap run isforked by the server .
198+ * place to put code that must be executed early inthe launch ofany new
199+ *server process. Note that this code will NOT be executed when a backend
200+ *or sub-bootstrap process is forked, unless we are in afork/exec
201+ *environment (ie EXEC_BACKEND isdefined) .
199202 *
200203 * XXX The need for code here is proof that the platform in question
201204 * is too brain-dead to provide a standard C execution environment
@@ -204,17 +207,10 @@ main(int argc, char *argv[])
204207static void
205208startup_hacks (const char * progname )
206209{
207- #if defined(__alpha )/* no __alpha__ ? */
208- #ifdef NOFIXADE
209- int buffer []= {SSIN_UACPROC ,UAC_SIGBUS |UAC_NOPRINT };
210- #endif
211- #endif /* __alpha */
212-
213-
214210/*
215211 * On some platforms, unaligned memory accesses result in a kernel trap;
216212 * the default kernel behavior is to emulate the memory access, but this
217- * results in a significant performance penalty. Weought to fix PGnot to
213+ * results in a significant performance penalty. Wewant PGnever to
218214 * make such unaligned memory accesses, so this code disables the kernel
219215 * emulation: unaligned accesses will result in SIGBUS instead.
220216 */
@@ -225,14 +221,21 @@ startup_hacks(const char *progname)
225221#endif
226222
227223#if defined(__alpha )/* no __alpha__ ? */
228- if (setsysinfo (SSI_NVPAIRS ,buffer ,1 , (caddr_t )NULL ,
229- (unsigned long )NULL )< 0 )
230- write_stderr ("%s: setsysinfo failed: %s\n" ,
231- progname ,strerror (errno ));
232- #endif
233- #endif /* NOFIXADE */
224+ {
225+ int buffer []= {SSIN_UACPROC ,UAC_SIGBUS |UAC_NOPRINT };
234226
227+ if (setsysinfo (SSI_NVPAIRS ,buffer ,1 , (caddr_t )NULL ,
228+ (unsigned long )NULL )< 0 )
229+ write_stderr ("%s: setsysinfo failed: %s\n" ,
230+ progname ,strerror (errno ));
231+ }
232+ #endif /* __alpha */
235233
234+ #endif /* NOFIXADE */
235+
236+ /*
237+ * Windows-specific execution environment hacking.
238+ */
236239#ifdef WIN32
237240{
238241WSADATA wsaData ;