mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +03:00
Refactor fork()-related code. We need to do various housekeeping tasks
before we can invoke fork() -- flush stdio buffers, save and restore the profiling timer on Linux with LINUX_PROFILE, and handle BeOS stuff. This patch moves that code into a single function, fork_process(), instead of duplicating it at the various callsites of fork(). This patch doesn't address the EXEC_BACKEND case; there is room for further cleanup there.
This commit is contained in:
@ -18,7 +18,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.12 2005/01/01 20:44:16 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.13 2005/03/10 07:14:03 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -33,6 +33,7 @@
|
||||
|
||||
#include "libpq/pqsignal.h"
|
||||
#include "miscadmin.h"
|
||||
#include "postmaster/fork_process.h"
|
||||
#include "postmaster/postmaster.h"
|
||||
#include "postmaster/syslogger.h"
|
||||
#include "pgtime.h"
|
||||
@ -451,28 +452,13 @@ SysLogger_Start(void)
|
||||
|
||||
pfree(filename);
|
||||
|
||||
/*
|
||||
* Now we can fork off the syslogger subprocess.
|
||||
*/
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
|
||||
#ifdef __BEOS__
|
||||
/* Specific beos actions before backend startup */
|
||||
beos_before_backend_startup();
|
||||
#endif
|
||||
|
||||
#ifdef EXEC_BACKEND
|
||||
switch ((sysloggerPid = syslogger_forkexec()))
|
||||
#else
|
||||
switch ((sysloggerPid = fork()))
|
||||
switch ((sysloggerPid = fork_process()))
|
||||
#endif
|
||||
{
|
||||
case -1:
|
||||
#ifdef __BEOS__
|
||||
/* Specific beos actions */
|
||||
beos_backend_startup_failed();
|
||||
#endif
|
||||
ereport(LOG,
|
||||
(errmsg("could not fork system logger: %m")));
|
||||
return 0;
|
||||
@ -480,10 +466,6 @@ SysLogger_Start(void)
|
||||
#ifndef EXEC_BACKEND
|
||||
case 0:
|
||||
/* in postmaster child ... */
|
||||
#ifdef __BEOS__
|
||||
/* Specific beos actions after backend startup */
|
||||
beos_backend_startup();
|
||||
#endif
|
||||
/* Close the postmaster's sockets */
|
||||
ClosePostmasterPorts(true);
|
||||
|
||||
|
Reference in New Issue
Block a user