diff options
author | 2018-12-08 21:03:51 +0000 | |
---|---|---|
committer | 2018-12-08 21:03:51 +0000 | |
commit | 3173a78d3f8745fbf68d2bd481fcab0cfe14477b (patch) | |
tree | 5cd8272d063f04af81e9fee81e238fbdf7147948 | |
parent | Basic regress test for kill -s SIG[NAME] (now failing) (diff) | |
download | wireguard-openbsd-3173a78d3f8745fbf68d2bd481fcab0cfe14477b.tar.xz wireguard-openbsd-3173a78d3f8745fbf68d2bd481fcab0cfe14477b.zip |
Fix kill [-SIGNAME | -s SIGNAME] and simplify
While the code intended to support both -s NAME and -s SIGNAME, the
tests performed were wrong. Replace convoluted code with less cryptic
conditionals. ok anton@
-rw-r--r-- | bin/ksh/trap.c | 24 | ||||
-rw-r--r-- | regress/bin/ksh/obsd-regress.t | 3 |
2 files changed, 12 insertions, 15 deletions
diff --git a/bin/ksh/trap.c b/bin/ksh/trap.c index fd4d9b2144b..e900714b578 100644 --- a/bin/ksh/trap.c +++ b/bin/ksh/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.32 2018/03/15 16:51:29 anton Exp $ */ +/* $OpenBSD: trap.c,v 1.33 2018/12/08 21:03:51 jca Exp $ */ /* * signal handling @@ -92,20 +92,18 @@ gettrap(const char *name, int igncase) return &sigtraps[n]; return NULL; } + + if (igncase && strncasecmp(name, "SIG", 3) == 0) + name += 3; + if (!igncase && strncmp(name, "SIG", 3) == 0) + name += 3; + for (p = sigtraps, i = NSIG+1; --i >= 0; p++) if (p->name) { - if (igncase) { - if (p->name && (!strcasecmp(p->name, name) || - (strlen(name) > 3 && !strncasecmp("SIG", - p->name, 3) && - !strcasecmp(p->name, name + 3)))) - return p; - } else { - if (p->name && (!strcmp(p->name, name) || - (strlen(name) > 3 && !strncmp("SIG", - p->name, 3) && !strcmp(p->name, name + 3)))) - return p; - } + if (igncase && strcasecmp(p->name, name) == 0) + return p; + if (!igncase && strcmp(p->name, name) == 0) + return p; } return NULL; } diff --git a/regress/bin/ksh/obsd-regress.t b/regress/bin/ksh/obsd-regress.t index 3cec4f878ea..d71897cb17e 100644 --- a/regress/bin/ksh/obsd-regress.t +++ b/regress/bin/ksh/obsd-regress.t @@ -1,4 +1,4 @@ -# $OpenBSD: obsd-regress.t,v 1.9 2018/12/08 12:12:45 jca Exp $ +# $OpenBSD: obsd-regress.t,v 1.10 2018/12/08 21:03:51 jca Exp $ # # ksh regression tests from OpenBSD @@ -502,5 +502,4 @@ description: support kill -s SIGNAME syntax stdin: kill -s SIGINFO $$ -expected-fail: yes --- |