chiark / gitweb /
tree-wide: drop 'This file is part of systemd' blurb
[elogind.git] / src / basic / signal-util.c
index bf4816fd6d938f599a5d316a7bd849a662b42cd2..e0e9444e4fc017ed7c1d14a18063c04a1ae9d58f 100644 (file)
@@ -1,7 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 /***
-  This file is part of systemd.
-
   Copyright 2015 Lennart Poettering
 ***/
 
@@ -234,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;
@@ -246,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");
@@ -287,17 +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;
-}
 
 #if 0 /// UNNEEDED by elogind
 void nop_signal_handler(int sig) {