summaryrefslogtreecommitdiffstats
path: root/src/basic/signal-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2024-10-31 15:33:44 +0100
committerLennart Poettering <lennart@poettering.net>2024-10-31 23:08:11 +0100
commit960b045875b11fd695a862912fd4e48fee4d3dd6 (patch)
tree236d229898a0257138b1133feeb1875930af2881 /src/basic/signal-util.c
parentcoredump: rename save_context() → context_parse_iovw() (diff)
downloadsystemd-960b045875b11fd695a862912fd4e48fee4d3dd6.tar.xz
systemd-960b045875b11fd695a862912fd4e48fee4d3dd6.zip
coredump: parse signal number at the same time as parsing other fields
Diffstat (limited to 'src/basic/signal-util.c')
-rw-r--r--src/basic/signal-util.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/basic/signal-util.c b/src/basic/signal-util.c
index 670040f1ad..ad9ed049f1 100644
--- a/src/basic/signal-util.c
+++ b/src/basic/signal-util.c
@@ -301,3 +301,19 @@ const struct sigaction sigaction_default = {
.sa_handler = SIG_DFL,
.sa_flags = SA_RESTART,
};
+
+int parse_signo(const char *s, int *ret) {
+ int sig, r;
+
+ r = safe_atoi(s, &sig);
+ if (r < 0)
+ return r;
+
+ if (!SIGNAL_VALID(sig))
+ return -EINVAL;
+
+ if (ret)
+ *ret = sig;
+
+ return 0;
+}