LCOV - code coverage report
Current view: top level - src/interfaces/libpq - legacy-pqsignal.c (source / functions) Coverage Total Hit
Test: PostgreSQL 20devel Lines: 0.0 % 11 0
Test Date: 2026-07-22 18:15:44 Functions: 0.0 % 1 0
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
Branches: 0.0 % 6 0

             Branch data     Line data    Source code
       1                 :             : /*-------------------------------------------------------------------------
       2                 :             :  *
       3                 :             :  * legacy-pqsignal.c
       4                 :             :  *    reliable BSD-style signal(2) routine stolen from RWW who stole it
       5                 :             :  *    from Stevens...
       6                 :             :  *
       7                 :             :  * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
       8                 :             :  * Portions Copyright (c) 1994, Regents of the University of California
       9                 :             :  *
      10                 :             :  *
      11                 :             :  * IDENTIFICATION
      12                 :             :  *    src/interfaces/libpq/legacy-pqsignal.c
      13                 :             :  *
      14                 :             :  *-------------------------------------------------------------------------
      15                 :             :  */
      16                 :             : #include "postgres_fe.h"
      17                 :             : 
      18                 :             : #include <signal.h>
      19                 :             : 
      20                 :             : 
      21                 :             : /*
      22                 :             :  * This version of pqsignal() exists only because pre-9.3 releases
      23                 :             :  * of libpq exported pqsignal(), and some old client programs still
      24                 :             :  * depend on that.  (Since 9.3, clients are supposed to get it from
      25                 :             :  * libpgport instead.)
      26                 :             :  *
      27                 :             :  * Because it is only intended for backwards compatibility, we freeze it
      28                 :             :  * with the semantics it had in 9.2; in particular, this has different
      29                 :             :  * behavior for SIGALRM than the version in src/port/pqsignal.c.
      30                 :             :  *
      31                 :             :  * libpq itself does not use this, nor does anything else in our code.
      32                 :             :  *
      33                 :             :  * src/include/port.h #define's pqsignal as pqsignal_fe or pqsignal_be,
      34                 :             :  * but here we want to export just plain "pqsignal".  We can't rely on
      35                 :             :  * port.h's extern declaration either.  (The point of those #define's
      36                 :             :  * is to ensure that no in-tree code accidentally calls this version.)
      37                 :             :  */
      38                 :             : #undef pqsignal
      39                 :             : 
      40                 :             : typedef void (*pqsigfunc_legacy) (int postgres_signal_arg);
      41                 :             : extern pqsigfunc_legacy pqsignal(int signo, pqsigfunc_legacy func);
      42                 :             : 
      43                 :             : pqsigfunc_legacy
      44                 :           0 : pqsignal(int signo, pqsigfunc_legacy func)
      45                 :             : {
      46                 :             : #ifndef WIN32
      47                 :             :     struct sigaction act,
      48                 :             :                 oact;
      49                 :             : 
      50                 :           0 :     act.sa_handler = func;
      51                 :           0 :     sigemptyset(&act.sa_mask);
      52                 :           0 :     act.sa_flags = 0;
      53         [ #  # ]:           0 :     if (signo != SIGALRM)
      54                 :           0 :         act.sa_flags |= SA_RESTART;
      55                 :             : #ifdef SA_NOCLDSTOP
      56         [ #  # ]:           0 :     if (signo == SIGCHLD)
      57                 :           0 :         act.sa_flags |= SA_NOCLDSTOP;
      58                 :             : #endif
      59         [ #  # ]:           0 :     if (sigaction(signo, &act, &oact) < 0)
      60                 :           0 :         return SIG_ERR;
      61                 :           0 :     return oact.sa_handler;
      62                 :             : #else                           /* WIN32 */
      63                 :             :     return signal(signo, func);
      64                 :             : #endif
      65                 :             : }
        

Generated by: LCOV version 2.0-1