When not compiling -DSMALL permit use of names RTMIN[+n] and RTMAX[-n]
(where n is a decimal integer in the range [0 .. SIGRTMAX-SIGRTMIN]. As usual a leading "sig" is ignored and the strings are case independent. Some implementations do not name the real time signals, and using labels like RTMIN+3 can be the only way they can be manipulated, so allow that technique (we still return the RTnn names on the inverse translation though). Because this is used by both kill(1) and sh(1) the kill and trap commands both gain access to the new notation (when !SMALL).
This commit is contained in:
parent
1690246c02
commit
631837b7c6
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: signalname.3,v 1.2 2017/05/14 12:35:46 wiz Exp $
|
||||
.\" $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
|
||||
|
@ -76,6 +76,17 @@ 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,
|
||||
|
@ -93,7 +104,8 @@ signal number.
|
|||
.Pp
|
||||
The
|
||||
.Fn signalnext
|
||||
function returns minus one (\-1) on error, if the given signal
|
||||
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,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: signalnumber.c,v 1.2 2018/01/04 20:57:29 kamil Exp $ */
|
||||
/* $NetBSD: signalnumber.c,v 1.3 2020/08/20 22:56:56 kre Exp $ */
|
||||
|
||||
/*
|
||||
* Software available to all and sundry without limitations
|
||||
|
@ -20,7 +20,9 @@
|
|||
#include "namespace.h"
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
/*
|
||||
* signalnumber()
|
||||
|
@ -42,6 +44,10 @@ int
|
|||
signalnumber(const char *name)
|
||||
{
|
||||
int i;
|
||||
#ifndef SMALL
|
||||
long offs;
|
||||
char *ep;
|
||||
#endif
|
||||
|
||||
if (strncasecmp(name, "sig", 3) == 0)
|
||||
name += 3;
|
||||
|
@ -50,5 +56,36 @@ signalnumber(const char *name)
|
|||
if (sys_signame[i] != NULL &&
|
||||
strcasecmp(name, sys_signame[i]) == 0)
|
||||
return i;
|
||||
|
||||
#ifndef SMALL
|
||||
if (strncasecmp(name, "rtm", 3) == 0) {
|
||||
name += 3;
|
||||
if (strncasecmp(name, "ax", 2) == 0)
|
||||
i = SIGRTMAX;
|
||||
else if (strncasecmp(name, "in", 2) == 0)
|
||||
i = SIGRTMIN;
|
||||
else
|
||||
return 0;
|
||||
name += 2;
|
||||
if (name[0] == '\0')
|
||||
return i;
|
||||
if (i == SIGRTMAX && name[0] != '-')
|
||||
return 0;
|
||||
if (i == SIGRTMIN && name[0] != '+')
|
||||
return 0;
|
||||
if (!isdigit((unsigned char)name[1]))
|
||||
return 0;
|
||||
offs = strtol(name+1, &ep, 10);
|
||||
if (ep == name+1 || *ep != '\0' ||
|
||||
offs < 0 || offs > SIGRTMAX-SIGRTMIN)
|
||||
return 0;
|
||||
if (name[0] == '+')
|
||||
i += (int)offs;
|
||||
else
|
||||
i -= (int)offs;
|
||||
if (i >= SIGRTMIN && i <= SIGRTMAX)
|
||||
return i;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue