public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin/main] Cygwin: kill(1): align real-time signal naming to Linux kill(1)
@ 2023-03-15 21:10 Corinna Vinschen
  0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2023-03-15 21:10 UTC (permalink / raw)
  To: cygwin-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=3dfb3217af2d1bc4be430675b6e591606aaa56fb

commit 3dfb3217af2d1bc4be430675b6e591606aaa56fb
Author:     Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Wed Mar 15 21:54:13 2023 +0100
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Wed Mar 15 22:08:04 2023 +0100

    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>

Diff:
---
 winsup/utils/kill.cc | 45 +++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 43 insertions(+), 2 deletions(-)

diff --git a/winsup/utils/kill.cc b/winsup/utils/kill.cc
index fc984c0b471e..a430b353720b 100644
--- a/winsup/utils/kill.cc
+++ b/winsup/utils/kill.cc
@@ -71,13 +71,51 @@ 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)
 {
@@ -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;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-15 21:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-15 21:10 [newlib-cygwin/main] Cygwin: kill(1): align real-time signal naming to Linux kill(1) Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).