if (ISDIGIT (*operand))
{
+ /* Note we don't put a limit on the maximum value passed,
+ because we're checking shell $? values here, and ksh for
+ example will add 256 to the signal value, thus being wider
+ than the number of WEXITSTATUS bits.
+ We could validate that values were not above say
+ ((WEXITSTATUS (~0) << 1) + 1), which would cater for ksh.
+ But some shells may use other adjustments in future to be
+ (forward) compatible with systems that support
+ wider exit status values as discussed at
+ http://austingroupbugs.net/view.php?id=947 */
+
char *endp;
long int l = (errno = 0, strtol (operand, &endp, 10));
int i = l;
SIGTERM=$(env kill -l HUP TERM | tail -n1) || fail=1
test $(env kill -l "$SIGTERM") = TERM || fail=1
+# Verify we only consider the lower "signal" bits,
+# to support ksh which just adds 256 to the signal value
+STD_TERM_STATUS=$(expr "$SIGTERM" + 128)
+KSH_TERM_STATUS=$(expr "$SIGTERM" + 256)
+test $(env kill -l $STD_TERM_STATUS $KSH_TERM_STATUS | uniq) = TERM || fail=1
+
# Verify invalid signal spec is diagnosed
-SIGINVAL=$(env kill -t | tail -n1 | cut -f1 -d' ')
-SIGINVAL=$(expr "$SIGINVAL" + 1)
-returns_ 1 env kill -l "$SIGINVAL" 0 || fail=1
+returns_ 1 env kill -l -1 || fail=1
+returns_ 1 env kill -l -1 0 || fail=1
returns_ 1 env kill -l INVALID TERM || fail=1
Exit $fail