errmsg("could not remove file \"%s\": %m",
                        LOG_METAINFO_DATAFILE)));
 
+   /*
+    * Initialize input sockets.
+    *
+    * Mark them all closed, and set up an on_proc_exit function that's
+    * charged with closing the sockets again at postmaster shutdown.
+    */
+   for (i = 0; i < MAXLISTEN; i++)
+       ListenSocket[i] = PGINVALID_SOCKET;
+
+   on_proc_exit(CloseServerPorts, 0);
+
    /*
     * If enabled, start up syslogger collection subprocess
     */
 
    /*
     * Establish input sockets.
-    *
-    * First, mark them all closed, and set up an on_proc_exit function that's
-    * charged with closing the sockets again at postmaster shutdown.
     */
-   for (i = 0; i < MAXLISTEN; i++)
-       ListenSocket[i] = PGINVALID_SOCKET;
-
-   on_proc_exit(CloseServerPorts, 0);
-
    if (ListenAddresses)
    {
        char       *rawstring;