#ifdef EXEC_BACKEND
if (argc > 1 && strncmp(argv[1], "--fork", 6) == 0)
- exit(SubPostmasterMain(argc, argv));
+ SubPostmasterMain(argc, argv); /* does not return */
#endif
#ifdef WIN32
if (argc > 1 && strcmp(argv[1], "--boot") == 0)
AuxiliaryProcessMain(argc, argv); /* does not return */
-
- if (argc > 1 && strcmp(argv[1], "--describe-config") == 0)
- exit(GucInfoMain());
-
- if (argc > 1 && strcmp(argv[1], "--single") == 0)
- exit(PostgresMain(argc, argv, get_current_username(progname)));
-
- exit(PostmasterMain(argc, argv));
+ else if (argc > 1 && strcmp(argv[1], "--describe-config") == 0)
+ GucInfoMain(); /* does not return */
+ else if (argc > 1 && strcmp(argv[1], "--single") == 0)
+ PostgresMain(argc, argv, get_current_username(progname)); /* does not return */
+ else
+ PostmasterMain(argc, argv); /* does not return */
+ abort(); /* should not get here */
}
static pid_t avlauncher_forkexec(void);
static pid_t avworker_forkexec(void);
#endif
-NON_EXEC_STATIC void AutoVacWorkerMain(int argc, char *argv[]);
-NON_EXEC_STATIC void AutoVacLauncherMain(int argc, char *argv[]);
+NON_EXEC_STATIC void AutoVacWorkerMain(int argc, char *argv[]) __attribute__((noreturn));
+NON_EXEC_STATIC void AutoVacLauncherMain(int argc, char *argv[]) __attribute__((noreturn));
static Oid do_start_worker(void);
static void launcher_determine_sleep(bool canlaunch, bool recursing,
static pid_t pgarch_forkexec(void);
#endif
-NON_EXEC_STATIC void PgArchiverMain(int argc, char *argv[]);
+NON_EXEC_STATIC void PgArchiverMain(int argc, char *argv[]) __attribute__((noreturn));
static void pgarch_exit(SIGNAL_ARGS);
static void ArchSigHupHandler(SIGNAL_ARGS);
static void ArchSigTermHandler(SIGNAL_ARGS);
static pid_t pgstat_forkexec(void);
#endif
-NON_EXEC_STATIC void PgstatCollectorMain(int argc, char *argv[]);
+NON_EXEC_STATIC void PgstatCollectorMain(int argc, char *argv[]) __attribute__((noreturn));
static void pgstat_exit(SIGNAL_ARGS);
static void pgstat_beshutdown_hook(int code, Datum arg);
static void pgstat_sighup_handler(SIGNAL_ARGS);
int pid, int exitstatus);
static void PostmasterStateMachine(void);
static void BackendInitialize(Port *port);
-static int BackendRun(Port *port);
-static void ExitPostmaster(int status);
+static void BackendRun(Port *port) __attribute__((noreturn));
+static void ExitPostmaster(int status) __attribute__((noreturn));
static int ServerLoop(void);
static int BackendStartup(Port *port);
static int ProcessStartupPacket(Port *port, bool SSLdone);
/*
* Postmaster main entry point
*/
-int
+void
PostmasterMain(int argc, char *argv[])
{
int opt;
*/
ExitPostmaster(status != STATUS_OK);
- return 0; /* not reached */
+ abort(); /* not reached */
}
BackendInitialize(port);
/* And run the backend */
- proc_exit(BackendRun(port));
+ BackendRun(port);
}
#endif /* EXEC_BACKEND */
* Shouldn't return at all.
* If PostgresMain() fails, return status.
*/
-static int
+static void
BackendRun(Port *port)
{
char **av;
*/
MemoryContextSwitchTo(TopMemoryContext);
- return (PostgresMain(ac, av, port->user_name));
+ PostgresMain(ac, av, port->user_name);
}
* have been inherited by fork() on Unix. Remaining arguments go to the
* subprocess FooMain() routine.
*/
-int
+void
SubPostmasterMain(int argc, char *argv[])
{
Port port;
CreateSharedMemoryAndSemaphores(false, 0);
/* And run the backend */
- proc_exit(BackendRun(&port));
+ BackendRun(&port); /* does not return */
}
if (strcmp(argv[1], "--forkboot") == 0)
{
/* Attach process to shared data structures */
CreateSharedMemoryAndSemaphores(false, 0);
- AuxiliaryProcessMain(argc - 2, argv + 2);
- proc_exit(0);
+ AuxiliaryProcessMain(argc - 2, argv + 2); /* does not return */
}
if (strcmp(argv[1], "--forkavlauncher") == 0)
{
/* Attach process to shared data structures */
CreateSharedMemoryAndSemaphores(false, 0);
- AutoVacLauncherMain(argc - 2, argv + 2);
- proc_exit(0);
+ AutoVacLauncherMain(argc - 2, argv + 2); /* does not return */
}
if (strcmp(argv[1], "--forkavworker") == 0)
{
/* Attach process to shared data structures */
CreateSharedMemoryAndSemaphores(false, 0);
- AutoVacWorkerMain(argc - 2, argv + 2);
- proc_exit(0);
+ AutoVacWorkerMain(argc - 2, argv + 2); /* does not return */
}
if (strcmp(argv[1], "--forkarch") == 0)
{
/* Do not want to attach to shared memory */
- PgArchiverMain(argc, argv);
- proc_exit(0);
+ PgArchiverMain(argc, argv); /* does not return */
}
if (strcmp(argv[1], "--forkcol") == 0)
{
/* Do not want to attach to shared memory */
- PgstatCollectorMain(argc, argv);
- proc_exit(0);
+ PgstatCollectorMain(argc, argv); /* does not return */
}
if (strcmp(argv[1], "--forklog") == 0)
{
/* Do not want to attach to shared memory */
- SysLoggerMain(argc, argv);
- proc_exit(0);
+ SysLoggerMain(argc, argv); /* does not return */
}
- return 1; /* shouldn't get here */
+ abort(); /* shouldn't get here */
}
#endif /* EXEC_BACKEND */
static pid_t syslogger_forkexec(void);
static void syslogger_parseArgs(int argc, char *argv[]);
#endif
+NON_EXEC_STATIC void SysLoggerMain(int argc, char *argv[]) __attribute__((noreturn));
static void process_pipe_input(char *logbuffer, int *bytes_in_logbuffer);
static void flush_pipe_input(char *logbuffer, int *bytes_in_logbuffer);
static void open_csvlogfile(void);
/* Prototypes for private functions */
static bool HandleReplicationCommand(const char *cmd_string);
-static int WalSndLoop(void);
+static void WalSndLoop(void) __attribute__((noreturn));
static void InitWalSnd(void);
static void WalSndHandshake(void);
static void WalSndKill(int code, Datum arg);
/* Main entry point for walsender process */
-int
+void
WalSenderMain(void)
{
MemoryContext walsnd_context;
SyncRepInitConfig();
/* Main loop of walsender */
- return WalSndLoop();
+ WalSndLoop();
}
/*
}
/* Main loop of walsender process */
-static int
+static void
WalSndLoop(void)
{
char *output_message;
whereToSendOutput = DestNone;
proc_exit(0);
- return 1; /* keep the compiler quiet */
+ abort(); /* keep the compiler quiet */
}
/* Initialize a per-walsender data structure for this walsender process */
* for the session.
* ----------------------------------------------------------------
*/
-int
+void
PostgresMain(int argc, char *argv[], const char *username)
{
const char *dbname;
/* If this is a WAL sender process, we're done with initialization. */
if (am_walsender)
- proc_exit(WalSenderMain());
+ {
+ WalSenderMain(); /* does not return */
+ abort();
+ }
/*
* process any libraries that should be preloaded at backend start (this
/* can't get here because the above loop never exits */
Assert(false);
- return 1; /* keep compiler quiet */
+ abort(); /* keep compiler quiet */
}
static bool displayStruct(mixedStruct *structToDisplay);
-int
+void
GucInfoMain(void)
{
struct config_generic **guc_vars;
printMixedStruct(var);
}
- return 0;
+ exit(0);
}
extern int numattr;
-extern void AuxiliaryProcessMain(int argc, char *argv[]);
+extern void AuxiliaryProcessMain(int argc, char *argv[]) __attribute__((noreturn));
extern void err_out(void);
extern void allow_immediate_pgstat_restart(void);
#ifdef EXEC_BACKEND
-extern void PgstatCollectorMain(int argc, char *argv[]);
+extern void PgstatCollectorMain(int argc, char *argv[]) __attribute__((noreturn));
#endif
extern void AutoVacuumUpdateDelay(void);
#ifdef EXEC_BACKEND
-extern void AutoVacLauncherMain(int argc, char *argv[]);
-extern void AutoVacWorkerMain(int argc, char *argv[]);
+extern void AutoVacLauncherMain(int argc, char *argv[]) __attribute__((noreturn));
+extern void AutoVacWorkerMain(int argc, char *argv[]) __attribute__((noreturn));
extern void AutovacuumWorkerIAm(void);
extern void AutovacuumLauncherIAm(void);
#endif
extern int CheckPointWarning;
extern double CheckPointCompletionTarget;
-extern void BackgroundWriterMain(void);
-extern void CheckpointerMain(void);
+extern void BackgroundWriterMain(void) __attribute__((noreturn));
+extern void CheckpointerMain(void) __attribute__((noreturn));
extern void RequestCheckpoint(int flags);
extern void CheckpointWriteDelay(int flags, double progress);
extern int pgarch_start(void);
#ifdef EXEC_BACKEND
-extern void PgArchiverMain(int argc, char *argv[]);
+extern void PgArchiverMain(int argc, char *argv[]) __attribute__((noreturn));
#endif
#endif /* _PGARCH_H */
extern const char *progname;
-extern int PostmasterMain(int argc, char *argv[]);
+extern void PostmasterMain(int argc, char *argv[]) __attribute__((noreturn));
extern void ClosePostmasterPorts(bool am_syslogger);
extern int MaxLivePostmasterChildren(void);
#ifdef EXEC_BACKEND
extern pid_t postmaster_forkexec(int argc, char *argv[]);
-extern int SubPostmasterMain(int argc, char *argv[]);
+extern void SubPostmasterMain(int argc, char *argv[]) __attribute__((noreturn));
extern Size ShmemBackendArraySize(void);
extern void ShmemBackendArrayAllocation(void);
#define _STARTUP_H
extern void HandleStartupProcInterrupts(void);
-extern void StartupProcessMain(void);
+extern void StartupProcessMain(void) __attribute__((noreturn));
extern void PreRestoreCommand(void);
extern void PostRestoreCommand(void);
extern bool IsPromoteTriggered(void);
extern void write_syslogger_file(const char *buffer, int count, int dest);
#ifdef EXEC_BACKEND
-extern void SysLoggerMain(int argc, char *argv[]);
+extern void SysLoggerMain(int argc, char *argv[]) __attribute__((noreturn));
#endif
#endif /* _SYSLOGGER_H */
/* GUC options */
extern int WalWriterDelay;
-extern void WalWriterMain(void);
+extern void WalWriterMain(void) __attribute__((noreturn));
#endif /* _WALWRITER_H */
extern PGDLLIMPORT walrcv_disconnect_type walrcv_disconnect;
/* prototypes for functions in walreceiver.c */
-extern void WalReceiverMain(void);
+extern void WalReceiverMain(void) __attribute__((noreturn));
/* prototypes for functions in walreceiverfuncs.c */
extern Size WalRcvShmemSize(void);
extern int max_wal_senders;
extern int replication_timeout;
-extern int WalSenderMain(void);
+extern void WalSenderMain(void) __attribute__((noreturn));
extern void WalSndSignals(void);
extern Size WalSndShmemSize(void);
extern void WalSndShmemInit(void);
/* ipc.c */
extern bool proc_exit_inprogress;
-extern void proc_exit(int code);
+extern void proc_exit(int code) __attribute__((noreturn));
extern void shmem_exit(int code);
extern void on_proc_exit(pg_on_exit_callback function, Datum arg);
extern void on_shmem_exit(pg_on_exit_callback function, Datum arg);
extern void assign_max_stack_depth(int newval, void *extra);
extern void die(SIGNAL_ARGS);
-extern void quickdie(SIGNAL_ARGS);
+extern void quickdie(SIGNAL_ARGS) __attribute__((noreturn));
extern void StatementCancelHandler(SIGNAL_ARGS);
extern void FloatExceptionHandler(SIGNAL_ARGS);
extern void RecoveryConflictInterrupt(ProcSignalReason reason); /* called from SIGUSR1
extern void client_read_ended(void);
extern const char *process_postgres_switches(int argc, char *argv[],
GucContext ctx);
-extern int PostgresMain(int argc, char *argv[], const char *username);
+extern void PostgresMain(int argc, char *argv[], const char *username) __attribute__((noreturn));
extern long get_stack_depth_rlimit(void);
extern void ResetUsage(void);
extern void ShowUsage(const char *title);
#ifndef HELP_CONFIG_H
#define HELP_CONFIG_H 1
-extern int GucInfoMain(void);
+extern void GucInfoMain(void) __attribute__((noreturn));
#endif