diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index f3ddf82..b8b97a1 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -4576,6 +4576,7 @@ internal_forkexec(int argc, char *argv[], Port *port) SECURITY_ATTRIBUTES sa; char paramHandleStr[32]; win32_deadchild_waitinfo *childinfo; + UINT errorMode; /* Make sure caller set up argv properly */ Assert(argc >= 3); @@ -4643,14 +4644,20 @@ retry: /* * Create the subprocess in a suspended state. This will be resumed later, * once we have written out the parameter file. + * + * Start the subprocess with the default error mode, so that a crash before + * main() generates a crash dump. */ + errorMode = SetErrorMode(0); if (!CreateProcess(NULL, cmdLine, NULL, NULL, TRUE, CREATE_SUSPENDED, NULL, NULL, &si, &pi)) { elog(LOG, "CreateProcess call failed: %m (error code %lu)", GetLastError()); + SetErrorMode(errorMode); return -1; } + SetErrorMode(errorMode); if (!save_backend_variables(param, port, pi.hProcess, pi.dwProcessId)) {