kill[all[5]],pkill: more correct, and smaller, SIGRTMIN/MAX code

function                                             old     new   delta
__libc_current_sigrtmin                                6       -      -6
__libc_current_sigrtmax                                6       -      -6
get_signum                                           339     295     -44
------------------------------------------------------------------------------
(add/remove: 0/3 grow/shrink: 0/1 up/down: 0/-56)             Total: -56 bytes

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
This commit is contained in:
Denys Vlasenko 2011-01-03 12:51:13 +01:00
parent 92ffe0571a
commit 7b276fc175

View File

@ -161,22 +161,31 @@ int FAST_FUNC get_signum(const char *name)
#if ENABLE_FEATURE_RTMINMAX #if ENABLE_FEATURE_RTMINMAX
# if defined(SIGRTMIN) && defined(SIGRTMAX) # if defined(SIGRTMIN) && defined(SIGRTMAX)
if (strncasecmp(name, "RTMAX", 5) == 0) { /* libc may use some rt sigs for pthreads and therefore "remap" SIGRTMIN/MAX,
if (!name[5]) * but we want to use "raw" SIGRTMIN/MAX. Underscored names, if exist, provide
return SIGRTMAX; * them. If they don't exist, fall back to non-underscored ones: */
if (name[5] == '-') { # if !defined(__SIGRTMIN)
i = bb_strtou(name + 6, NULL, 10); # define __SIGRTMIN SIGRTMIN
if (!errno && i <= SIGRTMAX - SIGRTMIN) # endif
return SIGRTMAX - i; # if !defined(__SIGRTMAX)
} # define __SIGRTMAX SIGRTMAX
} # endif
if (strncasecmp(name, "RTMIN", 5) == 0) { if (strncasecmp(name, "RTMIN", 5) == 0) {
if (!name[5]) if (!name[5])
return SIGRTMIN; return __SIGRTMIN;
if (name[5] == '+') { if (name[5] == '+') {
i = bb_strtou(name + 6, NULL, 10); i = bb_strtou(name + 6, NULL, 10);
if (!errno && i <= SIGRTMAX - SIGRTMIN) if (!errno && i <= __SIGRTMAX - __SIGRTMIN)
return SIGRTMIN + i; return __SIGRTMIN + i;
}
}
else if (strncasecmp(name, "RTMAX", 5) == 0) {
if (!name[5])
return __SIGRTMAX;
if (name[5] == '-') {
i = bb_strtou(name + 6, NULL, 10);
if (!errno && i <= __SIGRTMAX - __SIGRTMIN)
return __SIGRTMAX - i;
} }
} }
# endif # endif