1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
.\" $NetBSD: signalname.3,v 1.3 2020/08/20 22:56:56 kre Exp $
.\"
.\" Available to all and sundry, without restriction on use, or other
.\" limitations, and without fee. Also without any warranty of fitness
.\" for any purpose whatever.
.\"
.\" Licensed for any use, including redistribution in source
.\" and binary forms, with or without modifications, subject
.\" the following agreement:
.\"
.\" Licensee agrees to indemnify licensor, and distributor, for
.\" the full amount of any any claim made by the licensee against
.\" the licensor or distributor, for any action that results from
.\" any use or redistribution of this software, plus any costs
.\" incurred by licensor or distributor resulting from that claim.
.\"
.\" This licence must be retained with the software.
.\"
.Dd April 28, 2017
.Dt SIGNALNAME 3
.Os
.Sh NAME
.Nm signalname ,
.Nm signalnumber ,
.Nm signalnext
.Nd convert between signal numbers and names
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In signal.h
.Ft const char *
.Fn signalname "int sig"
.Ft int
.Fn signalnumber "const char *name"
.Ft int
.Fn signalnext "int sig"
.Sh DESCRIPTION
The
.Fn signalname
function takes a signal number
.Fa sig ,
and returns the name of that signal.
The name returned is locale independent,
and can be the string representation of one of the
signal names from
.In signal.h
such as
.Dv SIGHUP ,
.Dv SIGSTOP ,
.Dv SIGKILL ,
or some similar name,
but does not contain the leading
.Dq Dv SIG
prefix.
.Pp
The return value of
.Fn signalname
is
.Dv NULL
if
.Fa sig
does not represent a valid signal number,
or if the signal number given has no name.
.Pp
The
.Fn signalnumber
function converts the signal name
.Fa name
to the number corresponding to that signal.
The
.Fa name
is handled in a case-insensitive manner.
Any leading
.Dq Dv SIG
prefix in
.Fa name
is ignored.
.Pp
This implementation also accepts
.Dv rtmax Ns \&[\-n]
and
.Dv rtmin Ns \&[+n]
.Po
where the optional
.Ar n
is a decimal integer between 0 and SIGRTMAX\-SIGRTMIN
.Pc
to refer to the real time signals.
.Pp
The
.Fn signalnumber
function returns the signal number,
or zero (0) if the name given does not represent a valid signal.
.Pp
The
.Fn signalnext
function takes a signal number, and returns the number of the
next available bigger signal number.
When no higher signal numbers remain, it returns zero (0).
The parameter
.Fa sig
can be given as zero (0), to obtain the smallest implemented
signal number.
.Pp
The
.Fn signalnext
function returns minus one (\-1) on error,
that is, if the given signal
.Fa sig
is neither a valid signal number nor zero.
It returns zero when the input signal number,
.Fa sig ,
is the biggest available signal number.
Otherwise it returns the signal number of an implemented
signal that is larger than
.Fa sig
and such that there are no implemented signals with values
between
.Fa sig
and the value returned.
.Pp
The
.Fn signalnext
function can also be used to determine if a non-zero signal
number is valid or not (0 is always invalid, but cannot be
detected as such this way.)
Given the non-zero signal number to check as
.Fa sig ,
if
.Fn signalnext
returns anything other than minus one (\-1)
then
.Fa sig
represents a valid signal number.
If the return value is \-1 then
.Fa sig
is invalid.
.Sh SEE ALSO
.Xr kill 1 ,
.Xr intro 2 ,
.Xr psignal 3 ,
.Xr strsignal 3
.Sh HISTORY
The
.Fn signalname ,
.Fn signalnext ,
and
.Fn signalnumber
functions first appeared in
.Nx 8.0 .
|