PostgreSQL Source Code  git master
interrupt.c File Reference
#include "postgres.h"
#include <unistd.h>
#include "miscadmin.h"
#include "postmaster/interrupt.h"
#include "storage/ipc.h"
#include "storage/latch.h"
#include "storage/procsignal.h"
#include "utils/guc.h"
#include "utils/memutils.h"
Include dependency graph for interrupt.c:

Go to the source code of this file.

Functions

void HandleMainLoopInterrupts (void)
 
void SignalHandlerForConfigReload (SIGNAL_ARGS)
 
void SignalHandlerForCrashExit (SIGNAL_ARGS)
 
void SignalHandlerForShutdownRequest (SIGNAL_ARGS)
 

Variables

volatile sig_atomic_t ConfigReloadPending = false
 
volatile sig_atomic_t ShutdownRequestPending = false
 

Function Documentation

◆ HandleMainLoopInterrupts()

void HandleMainLoopInterrupts ( void  )

Definition at line 34 of file interrupt.c.

35 {
38 
40  {
41  ConfigReloadPending = false;
43  }
44 
46  proc_exit(0);
47 
48  /* Perform logging of memory contexts of this process */
51 }
volatile sig_atomic_t LogMemoryContextPending
Definition: globals.c:38
volatile sig_atomic_t ProcSignalBarrierPending
Definition: globals.c:37
@ PGC_SIGHUP
Definition: guc.h:72
void ProcessConfigFile(GucContext context)
volatile sig_atomic_t ShutdownRequestPending
Definition: interrupt.c:28
volatile sig_atomic_t ConfigReloadPending
Definition: interrupt.c:27
void proc_exit(int code)
Definition: ipc.c:104
void ProcessLogMemoryContextInterrupt(void)
Definition: mcxt.c:1041
void ProcessProcSignalBarrier(void)
Definition: procsignal.c:467

References ConfigReloadPending, LogMemoryContextPending, PGC_SIGHUP, proc_exit(), ProcessConfigFile(), ProcessLogMemoryContextInterrupt(), ProcessProcSignalBarrier(), ProcSignalBarrierPending, and ShutdownRequestPending.

Referenced by BackgroundWriterMain().

◆ SignalHandlerForConfigReload()

void SignalHandlerForConfigReload ( SIGNAL_ARGS  )

Definition at line 61 of file interrupt.c.

62 {
63  int save_errno = errno;
64 
65  ConfigReloadPending = true;
67 
68  errno = save_errno;
69 }
struct Latch * MyLatch
Definition: globals.c:58
void SetLatch(Latch *latch)
Definition: latch.c:566

References ConfigReloadPending, MyLatch, and SetLatch().

Referenced by ApplyLauncherMain(), ApplyWorkerMain(), autoprewarm_main(), AutoVacLauncherMain(), AutoVacWorkerMain(), BackgroundWriterMain(), CheckpointerMain(), PgArchiverMain(), PostgresMain(), SysLoggerMain(), WalReceiverMain(), WalSndSignals(), and WalWriterMain().

◆ SignalHandlerForCrashExit()

void SignalHandlerForCrashExit ( SIGNAL_ARGS  )

Definition at line 77 of file interrupt.c.

78 {
79  /*
80  * We DO NOT want to run proc_exit() or atexit() callbacks -- we're here
81  * because shared memory may be corrupted, so we don't want to try to
82  * clean up our transaction. Just nail the windows shut and get out of
83  * town. The callbacks wouldn't be safe to run from a signal handler,
84  * anyway.
85  *
86  * Note we do _exit(2) not _exit(0). This is to force the postmaster into
87  * a system reset cycle if someone sends a manual SIGQUIT to a random
88  * backend. This is necessary precisely because we don't clean up our
89  * shared memory state. (The "dead man switch" mechanism in pmsignal.c
90  * should ensure the postmaster sees this as a crash, too, but no harm in
91  * being doubly sure.)
92  */
93  _exit(2);
94 }

Referenced by InitPostmasterChild().

◆ SignalHandlerForShutdownRequest()

void SignalHandlerForShutdownRequest ( SIGNAL_ARGS  )

Definition at line 108 of file interrupt.c.

109 {
110  int save_errno = errno;
111 
112  ShutdownRequestPending = true;
113  SetLatch(MyLatch);
114 
115  errno = save_errno;
116 }

References MyLatch, SetLatch(), and ShutdownRequestPending.

Referenced by autoprewarm_main(), AutoVacLauncherMain(), BackgroundWriterMain(), CheckpointerMain(), PgArchiverMain(), WalReceiverMain(), and WalWriterMain().

Variable Documentation

◆ ConfigReloadPending

◆ ShutdownRequestPending