Fix handling of real-time signals.
This commit is contained in:
@@ -62,9 +62,22 @@ int
|
|||||||
sudo_sig2str(int signo, char *signame)
|
sudo_sig2str(int signo, char *signame)
|
||||||
{
|
{
|
||||||
#if defined(SIGRTMIN) && defined(SIGRTMAX)
|
#if defined(SIGRTMIN) && defined(SIGRTMAX)
|
||||||
/* Realtime signal support as per Solaris. */
|
/* Realtime signal support. */
|
||||||
if (signo >= SIGRTMIN && signo <= SIGRTMAX) {
|
if (signo >= SIGRTMIN && signo <= SIGRTMAX) {
|
||||||
(void)snprintf(signame, SIG2STR_MAX, "RTMIN+%d", (signo - SIGRTMIN));
|
const long rtmax = sysconf(_SC_RTSIG_MAX);
|
||||||
|
if (rtmax > 0) {
|
||||||
|
if (signo == SIGRTMIN) {
|
||||||
|
strlcpy(signame, "RTMIN", SIG2STR_MAX);
|
||||||
|
} else if (signo == SIGRTMAX) {
|
||||||
|
strlcpy(signame, "RTMAX", SIG2STR_MAX);
|
||||||
|
} else if (signo <= SIGRTMIN + (rtmax / 2) - 1) {
|
||||||
|
(void)snprintf(signame, SIG2STR_MAX, "RTMIN+%d",
|
||||||
|
(signo - SIGRTMIN));
|
||||||
|
} else {
|
||||||
|
(void)snprintf(signame, SIG2STR_MAX, "RTMAX-%d",
|
||||||
|
(SIGRTMAX - signo));
|
||||||
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -36,8 +36,9 @@
|
|||||||
#ifdef HAVE_STRINGS_H
|
#ifdef HAVE_STRINGS_H
|
||||||
# include <strings.h>
|
# include <strings.h>
|
||||||
#endif /* HAVE_STRINGS_H */
|
#endif /* HAVE_STRINGS_H */
|
||||||
#include <signal.h>
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "sudo_compat.h"
|
#include "sudo_compat.h"
|
||||||
|
|
||||||
@@ -117,9 +118,14 @@ sudo_str2sig(const char *signame, int *result)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (signame[5] == '+') {
|
if (signame[5] == '+') {
|
||||||
if (signame[6] == '1' || signame[6] == '2' || signame[6] == '3') {
|
if (isdigit((unsigned char)signame[6])) {
|
||||||
*result = SIGRTMIN + (signame[6] - '0');
|
const long rtmax = sysconf(_SC_RTSIG_MAX);
|
||||||
return 0;
|
const int off = signame[6] - '0';
|
||||||
|
|
||||||
|
if (rtmax > 0 && off < rtmax / 2) {
|
||||||
|
*result = SIGRTMIN + off;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -131,9 +137,14 @@ sudo_str2sig(const char *signame, int *result)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (signame[5] == '-') {
|
if (signame[5] == '-') {
|
||||||
if (signame[6] == '1' || signame[6] == '2' || signame[6] == '3') {
|
if (isdigit((unsigned char)signame[6])) {
|
||||||
*result = SIGRTMAX - (signame[6] - '0');
|
const long rtmax = sysconf(_SC_RTSIG_MAX);
|
||||||
return 0;
|
const int off = signame[6] - '0';
|
||||||
|
|
||||||
|
if (rtmax > 0 && off < rtmax / 2) {
|
||||||
|
*result = SIGRTMAX - off;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -141,10 +152,12 @@ sudo_str2sig(const char *signame, int *result)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (signo = 0; signo < NSIG; signo++) {
|
for (signo = 1; signo < NSIG; signo++) {
|
||||||
if (strcmp(signame, sudo_sys_signame[signo]) == 0) {
|
if (sudo_sys_signame[signo] != NULL) {
|
||||||
*result = signo;
|
if (strcmp(signame, sudo_sys_signame[signo]) == 0) {
|
||||||
return 0;
|
*result = signo;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user