LCOV - differential code coverage report
Current view: top level - src/port - pgstrsignal.c (source / functions) Coverage Total Hit UBC CBC
Current: c70b6db34ffeab48beef1fb4ce61bcad3772b8dd vs 06473f5a344df8c9594ead90a609b86f6724cff8 Lines: 80.0 % 5 4 1 4
Current Date: 2025-09-06 07:49:51 +0900 Functions: 100.0 % 1 1 1
Baseline: lcov-20250906-005545-baseline Branches: 50.0 % 2 1 1 1
Baseline Date: 2025-09-05 08:21:35 +0100 Line coverage date bins:
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
(360..) days: 80.0 % 5 4 1 4
Function coverage date bins:
(360..) days: 100.0 % 1 1 1
Branch coverage date bins:
(360..) days: 50.0 % 2 1 1 1

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : /*-------------------------------------------------------------------------
                                  2                 :                :  *
                                  3                 :                :  * pgstrsignal.c
                                  4                 :                :  *    Identify a Unix signal number
                                  5                 :                :  *
                                  6                 :                :  * On platforms compliant with modern POSIX, this just wraps strsignal(3).
                                  7                 :                :  * Elsewhere, we do the best we can.
                                  8                 :                :  *
                                  9                 :                :  * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
                                 10                 :                :  * Portions Copyright (c) 1994, Regents of the University of California
                                 11                 :                :  *
                                 12                 :                :  * IDENTIFICATION
                                 13                 :                :  *    src/port/pgstrsignal.c
                                 14                 :                :  *
                                 15                 :                :  *-------------------------------------------------------------------------
                                 16                 :                :  */
                                 17                 :                : 
                                 18                 :                : #include "c.h"
                                 19                 :                : 
                                 20                 :                : 
                                 21                 :                : /*
                                 22                 :                :  * pg_strsignal
                                 23                 :                :  *
                                 24                 :                :  * Return a string identifying the given Unix signal number.
                                 25                 :                :  *
                                 26                 :                :  * The result is declared "const char *" because callers should not
                                 27                 :                :  * modify the string.  Note, however, that POSIX does not promise that
                                 28                 :                :  * the string will remain valid across later calls to strsignal().
                                 29                 :                :  *
                                 30                 :                :  * This version guarantees to return a non-NULL pointer, although
                                 31                 :                :  * some platforms' versions of strsignal() reputedly do not.
                                 32                 :                :  *
                                 33                 :                :  * Note that the fallback cases just return constant strings such as
                                 34                 :                :  * "unrecognized signal".  Project style is for callers to print the
                                 35                 :                :  * numeric signal value along with the result of this function, so
                                 36                 :                :  * there's no need to work harder than that.
                                 37                 :                :  */
                                 38                 :                : const char *
 2456 tgl@sss.pgh.pa.us          39                 :CBC           3 : pg_strsignal(int signum)
                                 40                 :                : {
                                 41                 :                :     const char *result;
                                 42                 :                : 
                                 43                 :                :     /*
                                 44                 :                :      * If we have strsignal(3), use that --- but check its result for NULL.
                                 45                 :                :      */
                                 46                 :                : #ifdef HAVE_STRSIGNAL
                                 47                 :              3 :     result = strsignal(signum);
 2202                            48         [ -  + ]:              3 :     if (result == NULL)
 2202 tgl@sss.pgh.pa.us          49                 :UBC           0 :         result = "unrecognized signal";
                                 50                 :                : #else
                                 51                 :                : 
                                 52                 :                :     /*
                                 53                 :                :      * We used to have code here to try to use sys_siglist[] if available.
                                 54                 :                :      * However, it seems that all platforms with sys_siglist[] have also had
                                 55                 :                :      * strsignal() for many years now, so that was just a waste of code.
                                 56                 :                :      */
                                 57                 :                :     result = "(signal names not available on this platform)";
                                 58                 :                : #endif
                                 59                 :                : 
 2456 tgl@sss.pgh.pa.us          60                 :CBC           3 :     return result;
                                 61                 :                : }
        

Generated by: LCOV version 2.4-beta