public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/main] Cygwin: kill(1): align real-time signal naming to Linux kill(1) Date: Wed, 15 Mar 2023 21:10:51 +0000 (GMT) [thread overview] Message-ID: <20230315211051.E15963857C48@sourceware.org> (raw) 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;
reply other threads:[~2023-03-15 21:10 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230315211051.E15963857C48@sourceware.org \ --to=corinna@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).