build system: -fno-builtin-printf
[oweals/busybox.git] / sysklogd / klogd.c
index 3992081caf98daead392e3a34bcde894854a0b37..432ded1530be3054bf1f3ee9130d025a803833ee 100644 (file)
@@ -21,8 +21,7 @@
 //usage:       "[-c N] [-n]"
 //usage:#define klogd_full_usage "\n\n"
 //usage:       "Kernel logger\n"
-//usage:     "\nOptions:"
-//usage:     "\n       -c N    Only messages with level < N are printed to console"
+//usage:     "\n       -c N    Print to console messages more urgent than prio N (1-8)"
 //usage:     "\n       -n      Run in foreground"
 
 #include "libbb.h"
@@ -196,6 +195,8 @@ int klogd_main(int argc UNUSED_PARAM, char **argv)
 
        syslog(LOG_NOTICE, "klogd started: %s", bb_banner);
 
+       write_pidfile(CONFIG_PID_FILE_PATH "/klogd.pid");
+
        used = 0;
        while (!bb_got_signal) {
                int n;
@@ -239,11 +240,8 @@ int klogd_main(int argc UNUSED_PARAM, char **argv)
                        priority = LOG_INFO;
                        if (*start == '<') {
                                start++;
-                               if (*start) {
-                                       /* kernel never generates multi-digit prios */
-                                       priority = (*start - '0');
-                                       start++;
-                               }
+                               if (*start)
+                                       priority = strtoul(start, &start, 10);
                                if (*start == '>')
                                        start++;
                        }
@@ -259,6 +257,7 @@ int klogd_main(int argc UNUSED_PARAM, char **argv)
 
        klogd_close();
        syslog(LOG_NOTICE, "klogd: exiting");
+       remove_pidfile(CONFIG_PID_FILE_PATH "/klogd.pid");
        if (bb_got_signal)
                kill_myself_with_sig(bb_got_signal);
        return EXIT_FAILURE;