diff --git a/src/basic/signal-util.c b/src/basic/signal-util.c index 30ba8fb1114..cd93a98b502 100644 --- a/src/basic/signal-util.c +++ b/src/basic/signal-util.c @@ -232,11 +232,7 @@ int signal_from_string(const char *s) { const char *p; int signo, r; - /* Check that the input is a signal name. */ - signo = __signal_from_string(s); - if (signo > 0) - return signo; - + /* Check that the input is a signal number. */ if (safe_atoi(s, &signo) >= 0) { if (SIGNAL_VALID(signo)) return signo; @@ -244,6 +240,15 @@ int signal_from_string(const char *s) { return -ERANGE; } + /* Drop "SIG" prefix. */ + if (startswith(s, "SIG")) + s += 3; + + /* Check that the input is a signal name. */ + signo = __signal_from_string(s); + if (signo > 0) + return signo; + /* Check that the input is RTMIN or * RTMIN+n (0 <= n <= SIGRTMAX-SIGRTMIN). */ p = startswith(s, "RTMIN"); @@ -285,18 +290,6 @@ int signal_from_string(const char *s) { return -EINVAL; } -int signal_from_string_try_harder(const char *s) { - int signo; - assert(s); - - signo = signal_from_string(s); - if (signo <= 0) - if (startswith(s, "SIG")) - return signal_from_string(s+3); - - return signo; -} - void nop_signal_handler(int sig) { /* nothing here */ } diff --git a/src/basic/signal-util.h b/src/basic/signal-util.h index de2364fac4f..0c43467b63f 100644 --- a/src/basic/signal-util.h +++ b/src/basic/signal-util.h @@ -24,8 +24,6 @@ int sigprocmask_many(int how, sigset_t *old, ...); const char *signal_to_string(int i) _const_; int signal_from_string(const char *s) _pure_; -int signal_from_string_try_harder(const char *s); - void nop_signal_handler(int sig); static inline void block_signals_reset(sigset_t *ss) { diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 9699421cf14..d2a4c18bb86 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -4042,7 +4042,7 @@ int config_parse_set_status( r = safe_atoi(temp, &val); if (r < 0) { - val = signal_from_string_try_harder(temp); + val = signal_from_string(temp); if (val <= 0) { log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse value, ignoring: %s", word); diff --git a/src/login/loginctl.c b/src/login/loginctl.c index 1e9f50453b9..f73d2f0a759 100644 --- a/src/login/loginctl.c +++ b/src/login/loginctl.c @@ -1465,7 +1465,7 @@ static int parse_argv(int argc, char *argv[]) { break; case 's': - arg_signal = signal_from_string_try_harder(optarg); + arg_signal = signal_from_string(optarg); if (arg_signal < 0) { log_error("Failed to parse signal string %s.", optarg); return -EINVAL; diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c index 508d3775d32..c16f54c2832 100644 --- a/src/machine/machinectl.c +++ b/src/machine/machinectl.c @@ -2879,7 +2879,7 @@ static int parse_argv(int argc, char *argv[]) { break; case 's': - arg_signal = signal_from_string_try_harder(optarg); + arg_signal = signal_from_string(optarg); if (arg_signal < 0) { log_error("Failed to parse signal string %s.", optarg); return -EINVAL; diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 4dd61cb003f..23bc9402a8a 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -972,7 +972,7 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_KILL_SIGNAL: - arg_kill_signal = signal_from_string_try_harder(optarg); + arg_kill_signal = signal_from_string(optarg); if (arg_kill_signal < 0) { log_error("Cannot parse signal: %s", optarg); return -EINVAL; diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c index a3b9bee6ce7..78d5141053d 100644 --- a/src/shared/bus-unit-util.c +++ b/src/shared/bus-unit-util.c @@ -109,7 +109,7 @@ DEFINE_BUS_APPEND_PARSE("i", log_level_from_string); DEFINE_BUS_APPEND_PARSE("i", parse_errno); DEFINE_BUS_APPEND_PARSE("i", sched_policy_from_string); DEFINE_BUS_APPEND_PARSE("i", secure_bits_from_string); -DEFINE_BUS_APPEND_PARSE("i", signal_from_string_try_harder); +DEFINE_BUS_APPEND_PARSE("i", signal_from_string); DEFINE_BUS_APPEND_PARSE("i", socket_protocol_from_name); DEFINE_BUS_APPEND_PARSE_PTR("i", int32_t, int, ioprio_parse_priority); DEFINE_BUS_APPEND_PARSE_PTR("i", int32_t, int, parse_nice); @@ -1189,7 +1189,7 @@ static int bus_append_kill_property(sd_bus_message *m, const char *field, const if (streq(field, "KillSignal")) - return bus_append_signal_from_string_try_harder(m, field, eq); + return bus_append_signal_from_string(m, field, eq); return 0; } @@ -1298,7 +1298,7 @@ static int bus_append_service_property(sd_bus_message *m, const char *field, con r = safe_atoi(word, &val); if (r < 0) { - val = signal_from_string_try_harder(word); + val = signal_from_string(word); if (val < 0) return log_error_errno(r, "Invalid status or signal %s in %s: %m", word, field); diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index 45885618901..fec7c628022 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -927,7 +927,7 @@ int config_parse_signal( assert(rvalue); assert(sig); - r = signal_from_string_try_harder(rvalue); + r = signal_from_string(rvalue); if (r <= 0) { log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse signal name, ignoring: %s", rvalue); return 0; diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 49395ce02c3..a9461aa3911 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -7601,7 +7601,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) { break; case 's': - arg_signal = signal_from_string_try_harder(optarg); + arg_signal = signal_from_string(optarg); if (arg_signal < 0) { log_error("Failed to parse signal string %s.", optarg); return -EINVAL;