diff options
author | Pádraig Brady <P@draigBrady.com> | 2016-01-14 14:21:53 +0000 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2016-01-15 14:14:06 +0000 |
commit | 4c7d82f1f11a3e122befccde505a1dc4519a22e7 (patch) | |
tree | 5f3b7ef35f3d86b5c291c2a2ee05f9f3456b4137 /src | |
parent | b955a4fb6d503aa49242ea7d3addf528ae4bbe73 (diff) | |
download | coreutils-4c7d82f1f11a3e122befccde505a1dc4519a22e7.tar.xz |
tests: simplify invalid signal determination for kill -l
* src/operand2sig.c (operand2sig): Add a detailed comment explaining
why we validate even very large shell exit status values.
* tests/misc/kill.sh: Add a test case for the ksh scheme.
Simplify the INVALID signal number determination which also avoids
a false failure on systems like FreeBSD 10 with incomplete
signal list (caused by inaccurate NSIG).
Diffstat (limited to 'src')
-rw-r--r-- | src/operand2sig.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/operand2sig.c b/src/operand2sig.c index a9fede54b..62039db28 100644 --- a/src/operand2sig.c +++ b/src/operand2sig.c @@ -39,6 +39,17 @@ operand2sig (char const *operand, char *signame) 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; |