Header And Logo

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

Functions | Variables

pqsignal.c File Reference

#include "postgres.h"
#include "libpq/pqsignal.h"
Include dependency graph for pqsignal.c:

Go to the source code of this file.

Functions

void pqinitmask (void)

Variables

int UnBlockSig
int BlockSig
int StartupBlockSig

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().