NetBSD/lib/libc/gen/signalname.3

151 lines
3.4 KiB
Groff
Raw Normal View History

.\" $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 .