mirror of
https://github.com/opnsense/src.git
synced 2026-06-08 16:22:46 -04:00
trap: do not consider a bad signal name a fatal error.
POSIX explicitly prescribes this. Continue processing any other signals and return status 1.
This commit is contained in:
parent
80d5dd5fdb
commit
e3c2cd7237
2 changed files with 18 additions and 3 deletions
|
|
@ -149,6 +149,7 @@ trapcmd(int argc, char **argv)
|
|||
{
|
||||
char *action;
|
||||
int signo;
|
||||
int errors = 0;
|
||||
|
||||
if (argc <= 1) {
|
||||
for (signo = 0 ; signo < sys_nsig ; signo++) {
|
||||
|
|
@ -183,8 +184,10 @@ trapcmd(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
while (*argv) {
|
||||
if ((signo = sigstring_to_signum(*argv)) == -1)
|
||||
error("bad signal %s", *argv);
|
||||
if ((signo = sigstring_to_signum(*argv)) == -1) {
|
||||
out2fmt_flush("trap: bad signal %s\n", *argv);
|
||||
errors = 1;
|
||||
}
|
||||
INTOFF;
|
||||
if (action)
|
||||
action = savestr(action);
|
||||
|
|
@ -196,7 +199,7 @@ trapcmd(int argc, char **argv)
|
|||
INTON;
|
||||
argv++;
|
||||
}
|
||||
return 0;
|
||||
return errors;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
12
tools/regression/bin/sh/builtins/trap3.0
Normal file
12
tools/regression/bin/sh/builtins/trap3.0
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# $FreeBSD$
|
||||
|
||||
{
|
||||
trap '' garbage && exit 3
|
||||
trap - garbage && exit 3
|
||||
trap true garbage && exit 3
|
||||
trap '' 99999 && exit 3
|
||||
trap - 99999 && exit 3
|
||||
trap true 99999 && exit 3
|
||||
} 2>/dev/null
|
||||
test -n "$(trap true garbage TERM 2>/dev/null || trap)" || exit 3
|
||||
exit 0
|
||||
Loading…
Reference in a new issue