1.\"	$OpenBSD: psignal.3,v 1.14 2019/05/16 13:35:16 schwarze Exp $
2.\"
3.\" Copyright (c) 1983, 1991, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.Dd $Mdocdate: May 16 2019 $
31.Dt PSIGNAL 3
32.Os
33.Sh NAME
34.Nm psignal ,
35.Nm sys_siglist ,
36.Nm sys_signame
37.Nd system signal messages
38.Sh SYNOPSIS
39.In signal.h
40.Ft void
41.Fn psignal "unsigned int sig" "const char *s"
42.Vt extern char *sys_siglist[];
43.Vt extern char *sys_signame[];
44.Sh DESCRIPTION
45The
46.Fn psignal
47function locates the descriptive message
48string for the given signal number
49.Fa sig
50and writes it to the standard error.
51.Pp
52If the argument
53.Fa s
54is not
55.Dv NULL
56it is written to the standard error file descriptor
57prior to the message string,
58immediately followed by a colon and a space.
59If the signal number is not recognized
60(see
61.Xr sigaction 2
62for a list),
63the string
64.Dq Unknown signal
65is produced.
66.Pp
67The message strings can be accessed directly using the external array
68.Va sys_siglist ,
69indexed by recognized signal numbers.
70The external array
71.Va sys_signame
72is used similarly and contains short, upper-case abbreviations for signals
73which are useful for recognizing signal names in user input.
74The defined value
75.Dv NSIG
76contains a count of the strings in
77.Va sys_siglist
78and
79.Va sys_signame .
80.Sh SEE ALSO
81.Xr sigaction 2 ,
82.Xr perror 3 ,
83.Xr setlocale 3 ,
84.Xr strsignal 3
85.Sh HISTORY
86The
87.Fn psignal
88function appeared in
89.Bx 4.2 .
90.Sh CAVEATS
91On systems other than
92.Ox ,
93the
94.Dv LC_MESSAGES
95.Xr locale 1
96category can cause different strings to be printed instead of the
97normal signal descriptions; see CAVEATS in
98.Xr setlocale 3
99for details.
100