← Commit list

86981e3ad

Denys Vlasenko
Denys Vlasenko
2017-07-25
SUCCESS Duration: 144s

Subject

ash: allow "trap NUM [SIG]..." syntax

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

libbb/u_signal_names.c+1 -1
@@ -143,7 +143,7 @@ int FAST_FUNC get_signum(const char *name)
unsigned i;
i = bb_strtou(name, NULL, 10);
- if (!errno)
+ if (!errno && i < NSIG) /* for shells, we allow 0 too */
return i;
if (strncasecmp(name, "SIG", 3) == 0)
name += 3;
procps/kill.c+1 -1
@@ -188,7 +188,7 @@ int kill_main(int argc UNUSED_PARAM, char **argv)
arg = *++argv;
} /* else it must be -SIG */
signo = get_signum(arg);
- if (signo < 0) { /* || signo > MAX_SIGNUM ? */
+ if (signo < 0) {
bb_error_msg("bad signal name '%s'", arg);
return EXIT_FAILURE;
}
shell/ash.c+7 -2
@@ -12981,13 +12981,18 @@ trapcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
return 0;
}
+ /* Why the second check?
+ * "trap NUM [sig2]..." is the same as "trap - NUM [sig2]..."
+ * In this case, NUM is signal no, not an action.
+ */
action = NULL;
- if (ap[1])
+ if (ap[1] && !is_number(ap[0]))
action = *ap++;
+
exitcode = 0;
while (*ap) {
signo = get_signum(*ap);
- if (signo < 0 || signo >= NSIG) {
+ if (signo < 0) {
/* Mimic bash message exactly */
ash_msg("%s: invalid signal specification", *ap);
exitcode = 1;
shell/hush.c+1 -1
@@ -9745,7 +9745,7 @@ static int FAST_FUNC builtin_trap(char **argv)
sighandler_t handler;
sig = get_signum(*argv++);
- if (sig < 0 || sig >= NSIG) {
+ if (sig < 0) {
ret = EXIT_FAILURE;
/* Mimic bash message exactly */
bb_error_msg("trap: %s: invalid signal specification", argv[-1]);