LCOV - differential code coverage report
Current view: top level - src/port - pqsignal.c (source / functions) Coverage Total Hit UIC GIC CBC ECB DUB DCB
Current: Differential Code Coverage HEAD vs 15 Lines: 88.9 % 9 8 1 4 4 3 1 1
Current Date: 2023-04-08 17:13:01 Functions: 100.0 % 1 1 1 1
Baseline: 15 Line coverage date bins:
Baseline Date: 2023-04-08 15:09:40 (240..) days: 88.9 % 9 8 1 4 4 3
Legend: Lines: hit not hit Function coverage date bins:
(240..) days: 100.0 % 1 1 1

 Age         Owner                  TLA  Line data    Source code
                                  1                 : /*-------------------------------------------------------------------------
                                  2                 :  *
                                  3                 :  * pqsignal.c
                                  4                 :  *    reliable BSD-style signal(2) routine stolen from RWW who stole it
                                  5                 :  *    from Stevens...
                                  6                 :  *
                                  7                 :  * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
                                  8                 :  * Portions Copyright (c) 1994, Regents of the University of California
                                  9                 :  *
                                 10                 :  *
                                 11                 :  * IDENTIFICATION
                                 12                 :  *    src/port/pqsignal.c
                                 13                 :  *
                                 14                 :  *  We now assume that all Unix-oid systems have POSIX sigaction(2)
                                 15                 :  *  with support for restartable signals (SA_RESTART).  We used to also
                                 16                 :  *  support BSD-style signal(2), but there really shouldn't be anything
                                 17                 :  *  out there anymore that doesn't have the POSIX API.
                                 18                 :  *
                                 19                 :  *  Windows, of course, is resolutely in a class by itself.  In the backend,
                                 20                 :  *  we don't use this file at all; src/backend/port/win32/signal.c provides
                                 21                 :  *  pqsignal() for the backend environment.  Frontend programs can use
                                 22                 :  *  this version of pqsignal() if they wish, but beware that this does
                                 23                 :  *  not provide restartable signals on Windows.
                                 24                 :  *
                                 25                 :  * ------------------------------------------------------------------------
                                 26                 :  */
                                 27                 : 
                                 28                 : #include "c.h"
                                 29                 : 
                                 30                 : #include <signal.h>
                                 31                 : 
                                 32                 : #ifndef FRONTEND
                                 33                 : #include "libpq/pqsignal.h"
                                 34                 : #endif
                                 35                 : 
                                 36                 : /*
                                 37                 :  * Set up a signal handler, with SA_RESTART, for signal "signo"
                                 38                 :  *
                                 39                 :  * Returns the previous handler.
                                 40                 :  */
                                 41                 : pqsigfunc
 3675 tgl                        42 GIC      206587 : pqsignal(int signo, pqsigfunc func)
                                 43                 : {
                                 44                 : #if !(defined(WIN32) && defined(FRONTEND))
                                 45                 :     struct sigaction act,
                                 46                 :                 oact;
                                 47                 : 
                                 48          206587 :     act.sa_handler = func;
                                 49          206587 :     sigemptyset(&act.sa_mask);
 3585 tgl                        50 CBC      206587 :     act.sa_flags = SA_RESTART;
 3675 tgl                        51 ECB             : #ifdef SA_NOCLDSTOP
 3675 tgl                        52 CBC      206587 :     if (signo == SIGCHLD)
 3675 tgl                        53 GIC       20003 :         act.sa_flags |= SA_NOCLDSTOP;
 3675 tgl                        54 ECB             : #endif
 3675 tgl                        55 CBC      206587 :     if (sigaction(signo, &act, &oact) < 0)
 3675 tgl                        56 UIC           0 :         return SIG_ERR;
 3675 tgl                        57 CBC      206587 :     return oact.sa_handler;
                                 58                 : #else
                                 59                 :     /* Forward to Windows native signal system. */
 2778 tgl                        60 ECB             :     return signal(signo, func);
                                 61                 : #endif
                                 62                 : }
        

Generated by: LCOV version v1.16-55-g56c0a2a