aboutsummaryrefslogtreecommitdiff
path: root/winsup/utils
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2023-03-15 21:54:13 +0100
committerCorinna Vinschen <corinna@vinschen.de>2023-03-15 22:08:04 +0100
commit3dfb3217af2d1bc4be430675b6e591606aaa56fb (patch)
tree6e2bfd57add2f51de7ef50ea70da7e27a29e24c4 /winsup/utils
parent3569e3577c9de2b3a5cffba40597d2755bf5aacd (diff)
downloadnewlib-3dfb3217af2d1bc4be430675b6e591606aaa56fb.zip
newlib-3dfb3217af2d1bc4be430675b6e591606aaa56fb.tar.gz
newlib-3dfb3217af2d1bc4be430675b6e591606aaa56fb.tar.bz2
Cygwin: kill(1): align real-time signal naming to Linux kill(1)
Allow RT<N>, RTMIN+<N> and RTMAX-<N> for RT signals. Translate RT signal numbers to an "RT<N>" string. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup/utils')
-rw-r--r--winsup/utils/kill.cc45
1 files changed, 43 insertions, 2 deletions
diff --git a/winsup/utils/kill.cc b/winsup/utils/kill.cc
index fc984c0..a430b35 100644
--- a/winsup/utils/kill.cc
+++ b/winsup/utils/kill.cc
@@ -71,14 +71,52 @@ print_version ()
static const char *
strsigno (int signo)
{
- if (signo > 0 && signo < NSIG)
+ static char sigbuf[8];
+
+ if (signo > 0 && signo < SIGRTMIN)
return sys_sigabbrev[signo];
+ if (signo <= SIGRTMAX)
+ {
+ snprintf (sigbuf, sizeof sigbuf, "SIGRT%d", signo - SIGRTMIN);
+ return sigbuf;
+ }
static char buf[sizeof ("Unknown signal") + 32];
sprintf (buf, "Unknown signal %d", signo);
return buf;
}
static int
+strtortsig (const char *sig)
+{
+ bool neg = false;
+ char *endp = NULL;
+ int signo;
+
+ sig += 5;
+ if (!strcmp (sig, "MIN"))
+ return SIGRTMIN;
+ if (!strcmp (sig, "MAX"))
+ return SIGRTMAX;
+ if (!strncmp (sig, "MIN+", 4))
+ sig += 4;
+ else if (!strncmp (sig, "MAX-", 4))
+ {
+ sig += 4;
+ neg = true;
+ }
+ signo = strtoul (sig, &endp, 10);
+ if (!endp || *endp)
+ return 0;
+ if (neg)
+ signo = SIGRTMAX - signo;
+ else
+ signo = SIGRTMIN + signo;
+ if (signo < SIGRTMIN || signo > SIGRTMAX)
+ return 0;
+ return signo;
+}
+
+static int
getsig (const char *in_sig)
{
const char *sig;
@@ -92,7 +130,10 @@ getsig (const char *in_sig)
sprintf (buf, "SIG%-.20s", in_sig);
sig = buf;
}
- intsig = strtosigno (sig) ?: atoi (in_sig);
+ if (!strncmp (sig, "SIGRT", 5))
+ intsig = strtortsig (sig);
+ else
+ intsig = strtosigno (sig) ?: atoi (in_sig);
char *p;
if (!intsig && (strcmp (sig, "SIG0") != 0 && (strtol (in_sig, &p, 10) != 0 || *p)))
intsig = -1;