Header And Logo

PostgreSQL
| The world's most advanced open source database.

Defines | Functions | Variables

pqsignal.h File Reference

#include <signal.h>
Include dependency graph for pqsignal.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define PG_SETMASK(mask)   sigsetmask(*((int*)(mask)))
#define sigaddset(set, signum)   (*(set) |= (sigmask(signum)))
#define sigdelset(set, signum)   (*(set) &= ~(sigmask(signum)))

Functions

void pqinitmask (void)

Variables

int UnBlockSig
int BlockSig
int StartupBlockSig

Define Documentation

#define PG_SETMASK (   mask  )     sigsetmask(*((int*)(mask)))
#define sigaddset (   set,
  signum 
)    (*(set) |= (sigmask(signum)))

Definition at line 36 of file pqsignal.h.

Referenced by bgworker_quickdie(), quickdie(), and system().

#define sigdelset (   set,
  signum 
)    (*(set) &= ~(sigmask(signum)))

Function Documentation

void pqinitmask ( void   ) 

Definition at line 46 of file pqsignal.c.

References BlockSig, SIGABRT, SIGALRM, SIGCHLD, SIGCONT, sigdelset, SIGHUP, sigmask, SIGQUIT, SIGTRAP, SIGUSR1, SIGUSR2, SIGWINCH, StartupBlockSig, and UnBlockSig.

Referenced by PostgresMain(), and PostmasterMain().

{
#ifdef HAVE_SIGPROCMASK

    sigemptyset(&UnBlockSig);

    /* First set all signals, then clear some. */
    sigfillset(&BlockSig);
    sigfillset(&StartupBlockSig);

    /*
     * Unmark those signals that should never be blocked. Some of these signal
     * names don't exist on all platforms.  Most do, but might as well ifdef
     * them all for consistency...
     */
#ifdef SIGTRAP
    sigdelset(&BlockSig, SIGTRAP);
    sigdelset(&StartupBlockSig, SIGTRAP);
#endif
#ifdef SIGABRT
    sigdelset(&BlockSig, SIGABRT);
    sigdelset(&StartupBlockSig, SIGABRT);
#endif
#ifdef SIGILL
    sigdelset(&BlockSig, SIGILL);
    sigdelset(&StartupBlockSig, SIGILL);
#endif
#ifdef SIGFPE
    sigdelset(&BlockSig, SIGFPE);
    sigdelset(&StartupBlockSig, SIGFPE);
#endif
#ifdef SIGSEGV
    sigdelset(&BlockSig, SIGSEGV);
    sigdelset(&StartupBlockSig, SIGSEGV);
#endif
#ifdef SIGBUS
    sigdelset(&BlockSig, SIGBUS);
    sigdelset(&StartupBlockSig, SIGBUS);
#endif
#ifdef SIGSYS
    sigdelset(&BlockSig, SIGSYS);
    sigdelset(&StartupBlockSig, SIGSYS);
#endif
#ifdef SIGCONT
    sigdelset(&BlockSig, SIGCONT);
    sigdelset(&StartupBlockSig, SIGCONT);
#endif

/* Signals unique to startup */
#ifdef SIGQUIT
    sigdelset(&StartupBlockSig, SIGQUIT);
#endif
#ifdef SIGTERM
    sigdelset(&StartupBlockSig, SIGTERM);
#endif
#ifdef SIGALRM
    sigdelset(&StartupBlockSig, SIGALRM);
#endif
#else
    /* Set the signals we want. */
    UnBlockSig = 0;
    BlockSig = sigmask(SIGQUIT) |
        sigmask(SIGTERM) | sigmask(SIGALRM) |
    /* common signals between two */
        sigmask(SIGHUP) |
        sigmask(SIGINT) | sigmask(SIGUSR1) |
        sigmask(SIGUSR2) | sigmask(SIGCHLD) |
        sigmask(SIGWINCH) | sigmask(SIGFPE);
    StartupBlockSig = sigmask(SIGHUP) |
        sigmask(SIGINT) | sigmask(SIGUSR1) |
        sigmask(SIGUSR2) | sigmask(SIGCHLD) |
        sigmask(SIGWINCH) | sigmask(SIGFPE);
#endif
}


Variable Documentation

int BlockSig

Definition at line 26 of file pqsignal.c.

Referenced by BackendInitialize(), and pqinitmask().