1.\" Copyright (c) 1983, 1991, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 3. Neither the name of the University nor the names of its contributors 13.\" may be used to endorse or promote products derived from this software 14.\" without specific prior written permission. 15.\" 16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26.\" SUCH DAMAGE. 27.\" 28.Dd September 23, 2025 29.Dt PSIGNAL 3 30.Os 31.Sh NAME 32.Nm psignal , 33.Nm psiginfo , 34.Nm strsignal , 35.Nm sys_siglist , 36.Nm sys_signame , 37.Nm sig2str , 38.Nm str2sig 39.Nd system signal messages 40.Sh LIBRARY 41.Lb libc 42.Sh SYNOPSIS 43.In signal.h 44.Ft void 45.Fn psignal "int sig" "const char *s" 46.Ft void 47.Fn psiginfo "const siginfo_t *si" "const char *s" 48.Vt extern const char * const sys_siglist[] ; 49.Vt extern const char * const sys_signame[] ; 50.In string.h 51.Ft "char *" 52.Fn strsignal "int sig" 53.Ft int 54.Fn sig2str "int signum" "char *str" 55.Ft int 56.Fn str2sig "char *str" "int *pnum" 57.Sh DESCRIPTION 58The 59.Fn psignal 60and 61.Fn strsignal 62functions locate the descriptive message 63string for a signal number. 64.Pp 65The 66.Fn strsignal 67function accepts a signal number argument 68.Fa sig 69and returns a pointer to the corresponding message string. 70.Pp 71The 72.Fn psignal 73function accepts a signal number argument 74.Fa sig 75and writes it to the standard error. 76If the argument 77.Fa s 78is 79.Pf non- Dv NULL 80and does not point to the null character, 81.Fa s 82is written to the standard error file descriptor 83prior to the message string, 84immediately followed by a colon and a space. 85If the signal number is not recognized 86.Pq Xr sigaction 2 , 87the string 88.Dq "Unknown signal" 89is produced. 90.Pp 91The 92.Fn psiginfo 93function is similar to 94.Fn psignal , 95except that the signal number information is taken from the 96.Fa si 97argument which is a 98.Vt siginfo_t 99structure. 100.Pp 101The message strings can be accessed directly 102through the external array 103.Va sys_siglist , 104indexed by recognized signal numbers. 105The external array 106.Va sys_signame 107is used similarly and 108contains short, upper-case abbreviations for signals 109which are useful for recognizing signal names 110in user input. 111The defined variable 112.Dv NSIG 113contains a count of the strings in 114.Va sys_siglist 115and 116.Va sys_signame . 117.Pp 118The 119.Fn sig2str 120function translates the signal number 121.Fa signum 122to the signal name, without the 123.Dq SIG 124prefix, and stores it at the location specified by 125.Fa str , 126which should be large enough to hold the name and the terminating 127.Dv NUL 128byte. 129The symbol 130.Dv SIG2STR_MAX 131gives the maximum size in bytes required. 132.Pp 133The 134.Fn str2sig 135function translates the signal name 136.Fa str 137to a signal number and stores it in the location referenced by 138.Fa pnum . 139The name in 140.Fa str 141can be either the name of the signal, with or without the 142.Dq SIG 143prefix, or a decimal number. 144.Sh RETURN VALUES 145The 146.Fn sig2str 147and 148.Fn str2sig 149return 0 on success and -1 on translation failure. 150In the latter case the memory to store the translation result is left intact. 151.Sh SEE ALSO 152.Xr sigaction 2 , 153.Xr perror 3 , 154.Xr strerror 3 155.Sh STANDARDS 156The 157.Fn psignal 158and 159.Fn psiginfo 160functions are defined by 161.St -p1003.1-2008 162, while the 163.Fn sig2str 164and 165.Fn str2sig 166functions are defined by 167.St -p1003.1-2024 . 168.Sh HISTORY 169The 170.Fn psignal 171function appeared in 172.Bx 4.2 . 173The 174.Fn psiginfo 175function appeared in 176.Fx 14.3 , 177.Nx 6.0 , 178and 179.Dx 4.1 . 180The 181.Fn sig2str 182and 183.Fn str2sig 184functions appeared in 185.Fx 15.0 . 186